【问题标题】:How to access file after Downloading to Memory, Firebase?Firebase下载到内存后如何访问文件?
【发布时间】: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


【解决方案1】:

您想如何访问该文件? 默认情况下,您可以使用new ByteArrayOutputStream() 作为存储。 https://stackoverflow.com/a/17595282/6916890

【讨论】:

    猜你喜欢
    • 2020-02-15
    • 2021-02-16
    • 1970-01-01
    • 2019-05-30
    • 1970-01-01
    • 1970-01-01
    • 2017-08-22
    • 1970-01-01
    • 2017-03-08
    相关资源
    最近更新 更多