简体   繁体   English

使用Firebase下载多个文件

[英]Download multiple files with Firebase

im trying to get 2 files from my firebase storage, they are in a folder called Ara , so the files there are 2 xxx.txt and yyy.txt (lets call them this way) 我正在尝试从我的Firebase存储中获取2个文件,它们位于一个名为Ara的文件夹中,因此文件中有2个xxx.txt和yyy.txt(以这种方式调用它们)

so for testing i just run this method 所以为了测试我只是运行这种方法

 private void traerPictosFirebase(){

        File localFile = null;
        try {
            localFile = File.createTempFile("xxx","txt");
        } catch (IOException e) {
            e.printStackTrace();
        }

        mStorageRef.child("Archivos_Paises/Ara").getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {


//here i want to know if i downloaded succefully the file and find the path of it

            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {

            }
        });



    }

So, now i want to do 2 things, first one is how i know if the file was downloaded to my device, in the onSuccess and second i want to donwload the two files, not just one 所以,现在我想要做的两件事情,第一个是我怎么知道,如果该文件被下载到我的设备,在onSuccess和第二我想donwload两个文件,而不只是一个

thanks 谢谢

The fact that the onSuccess() callback was even invoked indicates that the file was successfully downloaded. 甚至调用了onSuccess()回调的事实表明该文件已成功下载。 You don't need any other confirmation. 您不需要任何其他确认。

If you want to download two files, then you'll need to make two calls to getFile() and deal with both of their tasks. 如果要下载两个文件,则需要两次调用getFile()并处理它们的两个任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM