我正在使用firebase下载和File.createTempFile来下载文件。 onSuccess方法记录消息,但它不会创建下载的文件。这是我的代码
public void downloadFile(){
StorageReference islandRef = storageRef.child("mountains.jpg");
File localFile = null;
try {
localFile = File.createTempFile("images", "jpg");
} catch (IOException e) {
e.printStackTrace();
}
islandRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.i("msg","ok");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
Log.i("msg", exception.toString());
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
}
});
}