我正确上传了文件,现在我要下载,没有错误,但logcat表示下载已完成,但是我无法在手机存储器中找到文件 其他版本的代码会产生错误
代码:
public void download(){
try{
//DatabaseReference databaseReference= FirebaseDatabase.getInstance().getReference();
FirebaseStorage storage = FirebaseStorage.getInstance();
//StorageReference storageRef = storage.getReferenceFromUrl(url);
final StorageReference storageRef = storage
.getReferenceFromUrl("gs://the-piraty-book-alpha1.appspot.com/arquivos/")
.child(nome);
File storagePath = new File( Environment.getExternalStorageDirectory(),"TPB");
if(!storagePath.exists()) {
storagePath.mkdirs();
}
File localFile = null;
localFile = File.createTempFile("arquivo","pdf");
final File finalLocalFile = localFile;
FileDownloadTask task = storageRef.getFile(localFile);
task.addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.e("firebase ",";local tem file created created " + finalLocalFile.toString());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.e("firebase ",";local tem file not created created " +exception.toString());
}
});
}catch (IOException e){
}
}
10-01 13:35:51.118 31218-31218/ktm.com.menu E/firebase: ;local tem file created created /data/user/0/ktm.com.menu/cache/arquivo572065630pdf
在我的手机中找不到
,我的清单
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.STORAGE" />