How To Get The Local Path From A File Downloaded From Firebase Storage
I am a bit confused with the Firebase documentation: https://firebase.google.com/docs/storage/android/download-files I am trying to download a file from Firebase through the URL of
Solution 1:
From the docs :-
The getFile() method downloads a file directly to a local device.
So, instead of doing what you're doing, you can first create a temporary file. Following is an example :-
FilelocalFile= File.createTempFile("images", "jpg");
After that, you pass this localFile
as a parameter to your getFile()
method ( instead of passing downloadURL
). So, when your onSuccess()
is fired, this file is populated with the data that has been downloaded and you can access it for whatever you need. Something like this :-
mStorageReference.getFile(localFile).addOnSuccessListener(newOnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@OverridepublicvoidonSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
//localFile contains your downloaded data
}
});
Note that in this example, the localFile
is temporary, but you can create a File at your specified path too. It depends on your use case.
Post a Comment for "How To Get The Local Path From A File Downloaded From Firebase Storage"