【发布时间】:2017-08-20 00:08:11
【问题描述】:
我手动将 pdf 文件上传到 Firebase Storage。现在,我使用 Firebase 存储文档中提到的“下载到本地文件”方法从我的应用程序下载了该文件,但我找不到下载的文件 我在哪里可以找到我下载的文件我得到“下载成功” 如果需要对代码进行任何更改,请告诉我
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");
// ...
}
});
//
}
});
【问题讨论】: