【发布时间】:2020-05-12 02:53:37
【问题描述】:
我已经为downloading Firebase Storage file to memory 实现了下面的代码。所以,下一步是我要访问该文件。在这种情况下,我该如何实现?
//Download to memory
public void downloadToMemory(StorageReference sRefChild, String selectedFile)
{
final long ONE_MEGABYTE = 1024 * 1024 *5;
sRefChild.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
System.out.println("On success!");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
System.out.println("Handle failure...");
}
});
【问题讨论】:
-
来自云存储的数据在
byte[] bytes中可用。你可以在那里做任何你想做的事情,包括writing it to a file。但是如果你想把它存储在一个文件中,你还不如直接通过 API 来做,而不是先把它加载到内存中。见downloading to a local file。 -
啊,好的,非常感谢!我已经使用了下载到本地文件的方法,现在我可以访问该文件了,谢谢=D
标签: java firebase google-cloud-storage firebase-storage downloadfile