如何解决提取链接在Firebase android Java中也算作下载操作
在我的android应用程序中,我的Firebase云存储(而非Firestore)中有300个文件。有两件事,比如获取链接,然后我们使用它来下载。在Firebase定价中
如您在上面看到的,费用仅用于下载和上传操作。但是现在,当我从firebase中获取链接时是否将其计为下载操作,我感到困惑。这是一些获取链接的代码。
storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// Got the download URL
// will this counter as a operation
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
下载文件的实际代码如下
void startDownloading(final String DownloadUrl,String DownloadPath,String DownloadName) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
final File file = new File(StringManager.phoneStorageLocation + "/"
+ DownloadPath + "/" + DownloadName);
try {
URL url = new URL(DownloadUrl);
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
FileOutputStream fos = new FileOutputStream(file);
fos.getChannel().transferFrom(rbc,Long.MAX_VALUE);
fos.close();
rbc.close();
} catch (IOException ignored) {
}
}
上面是我实际使用链接下载文件的代码。在这里肯定或显然会被视为下载操作。
所以我的问题又是,将链接获取计为下载操作吗?并且获取元数据将被视为一项操作,该操作会花费我们大量资金。摘要-除上载或下载外的其他操作(例如元数据,链接,获取文件名等),如果我们使用它们,是否会花钱。
解决方法
将获取链接计为下载操作吗?
否。
并且将获取元数据视为一项需要花费我们资金的操作
根据pricing overview for Cloud Storage,检索对象元数据是B类操作,每10,000个操作$ 0.004。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。