How do I get the file download url after uploading a file in Android Firebase storage? getDownloadUrl() not working


Hasib Akter:

In my new Android Firebase project, I use the com.google.firebase:firebase-storage:16.0.1library.

I get the following error:

enter image description here

I opened a project with the library firebase-storage:15.0.2and taskSnapshot.getDownloadUrl();its collaborating on the project. But it doesn't work after using the latest dependency library.

Now, how can I get the url of the file?

How can I put the file download link?

Hasib Akter:

I have found a solution to my problem 2.

Firebase Google Docs :

//add file on Firebase and got Download Link
filePath.putFile(imageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
    @Override
    public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
        if (!task.isSuccessful()){
            throw task.getException();
        }
        return filePath.getDownloadUrl();
    }
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
    @Override
    public void onComplete(@NonNull Task<Uri> task) {
        if (task.isSuccessful()){
            Uri downUri = task.getResult();
            Log.d(TAG, "onComplete: Url: "+ downUri.toString());
        }
    }
});

Another solution!

It 's easier and smaller than Google Docs Firebase, I'd use it:

filePath.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
    @Override
    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
        filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
            @Override
            public void onSuccess(Uri uri) {
                Log.d(TAG, "onSuccess: uri= "+ uri.toString());
            }
        });
    }
});

Related


How to get URL getDownloadURL from Firebase Storage

Jonathan Fager: I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; }

How to get URL getDownloadURL from Firebase Storage

Jonathan Fager I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; } }

How to get URL getDownloadURL from Firebase Storage

Jonathan Fager: I'm trying to get "Long Persistent Download Links" for a file in a Firebase bucket. I have changed its permissions to service firebase.storage { match /b/project-xxx.appspot.com/o { match /{allPaths=**} { allow read, write; }

Generate Firebase Storage download URL before uploading file

Irma Levy Is there a way in Firebase Storage to generate a download url that doesn't point to anything, so that the file can be uploaded to that url later? Like this (in Kotlin): fun generateItemPhotoUrl(id: String) = storageRef.child("$Id/${genera

Generate Firebase Storage download URL before uploading file

Irma Levy Is there a way in Firebase Storage to generate a download url that doesn't point to anything, so that the file can be uploaded to that url later? Like this (in Kotlin): fun generateItemPhotoUrl(id: String) = storageRef.child("$Id/${genera

Generate Firebase Storage download URL before uploading file

Irma Levy Is there a way in Firebase Storage to generate a download url that doesn't point to anything, so that the file can be uploaded to that url later? Like this (in Kotlin): fun generateItemPhotoUrl(id: String) = storageRef.child("$Id/${genera

Generate Firebase Storage download URL before uploading file

Irma Levy Is there a way in Firebase Storage to generate a download url that doesn't point to anything, so that the file can be uploaded to that url later? Like this (in Kotlin): fun generateItemPhotoUrl(id: String) = storageRef.child("$Id/${genera

Generate Firebase Storage download URL before uploading file

Irma Levy Is there a way in Firebase Storage to generate a download url that doesn't point to anything, so that the file can be uploaded to that url later? Like this (in Kotlin): fun generateItemPhotoUrl(id: String) = storageRef.child("$Id/${genera

Get download URL of Firebase Storage file

birdcage I have a mobile app that requires Firebase registration to backup/restore custom user data in Firebase. I would like to know if an authorized user can somehow get the url of his own stored file and download it to his computer. Frank Vampfelen If a use