从Firebase存储下载的文件是否已存储? [英] file downloaded from Firebase storage get stored?

查看:63
本文介绍了从Firebase存储下载的文件是否已存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我手动将pdf文件上传到Firebase Storage.现在,我使用Firebase存储文档中提到的下载到本地文件"方法从我的应用程序下载了该文件,但是找不到下载的文件我在哪里可以找到我下载的文件,并获得下载成功"如果需要在代码plz中进行任何更改,请告诉我

I manually uploaded a pdf file to Firebase Storage . Now, I downloaded that file from my app using the method 'Download to a local file' as mentioned in the Firebase Storage documentation, but I am not able to find the downloaded file Where can i find my downloaded file i am getting "Download Success" if any changes need to be done in code plz let me know

t3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mStorageRef = FirebaseStorage.getInstance().getReference();
        //Upload
          //
            //Download
            File localFile = null;
            try {
                localFile = File.createTempFile("file", "pdf");
            } catch (IOException e) {
                e.printStackTrace();
            }

            File storagePath = new File(Environment.getExternalStorageDirectory(), "directory_name");

            if(!storagePath.exists()) {
                storagePath.mkdirs();
            }

            final File myFile = new File(storagePath,"IBM2013507.pdf");

            StorageReference riversRef = mStorageRef.child("IBM2013507.pdf");


            riversRef.getFile(myFile)
                    .addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                            // Successfully downloaded data to local file
                        Log.v("Download","Success");
                            // ...taskSnapshot
                        }
                    }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    // Handle failed download
                    Log.v("Download","unSuccess");
                    // ...
                }
            });
            //

        }
    });

推荐答案

您在代码中定义了下载位置:

You defined the download location in your code:

File storagePath = new File(Environment.getExternalStorageDirectory(), "directory_name");
final File myFile = new File(storagePath,"IBM2013507.pdf");

由于要下载到 myFile ,因此可以期望在设备的外部存储目录中的"directory_name"文件夹中找到文件名为"IBM2013507.pdf"的文件.

Since you're downloading to myFile, you can expect the find the file on the device's external storage directory in the "directory_name" folder with the file name "IBM2013507.pdf".

如果您不知道它在哪里,请尝试打印 myFile 的值以查看完整路径.

If you don't know where that is, try printing the value of myFile to see the full path.

这篇关于从Firebase存储下载的文件是否已存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆