Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Firebase after uploading Image how can I get Url? [duplicate]

Right now, I'm fetching image from storage of Firebase by using below code:

mStoreRef.child("photos/" + model.getBase64Image())           .getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {                         @Override                         public void onSuccess(Uri uri) {                             // Got the download URL for 'photos/profile.png'                          }                     }).addOnFailureListener(new OnFailureListener() {                         @Override                         public void onFailure(@NonNull Exception exception) {                             // Handle any errors                             Toast.makeTextthis, "image not dowloaded", Toast.LENGTH_SHORT).show();                         }                     }); 

How to get this URL ?

Is it possible to get this URL which is shown in image?

like image 422
Rjz Satvara Avatar asked Oct 21 '16 12:10

Rjz Satvara


People also ask

How can I get URL of uploaded image in Firebase storage?

Image URL is obtained by uploading an image to firebase bucket and then that can return back a URL that URL is a permanent URL which can be open anywhere. Then a user can use this URL for any purpose in its application.

How do I get the URL of files from Firebase storage?

Firebase Download URLs The download token is created automatically whenever a file is uploaded to Cloud Storage for Firebase. It's a random UUIDv4, which makes the URL hard to guess. To retrieve a download URL, your client app needs to call the getDownloadUrl() method on the file reference.

Do Firebase storage URLs expire?

The Firebase Storage token does not expire (see Stack Overflow). Therefore, without any other modifications, our downloadUrl also never expires and remains available. But, is it possible in the Firebase Console to invalidate a specific URL.

How do I remove image URL from Firebase storage?

To delete a file, first create a reference to that file. Then call the delete() method on that reference, which returns a Promise that resolves, or an error if the Promise rejects.


1 Answers

Follow this link -https://firebase.google.com/docs/storage/android/download-files#download_data_via_url

    storageRef.child("users/me/profile.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {         @Override         public void onSuccess(Uri uri) {             // Got the download URL for 'users/me/profile.png'             Uri downloadUri = taskSnapshot.getMetadata().getDownloadUrl();             generatedFilePath = downloadUri.toString(); /// The string(file link) that you need         }     }).addOnFailureListener(new OnFailureListener() {         @Override         public void onFailure(@NonNull Exception exception) {             // Handle any errors         }     }); 
like image 134
Shamik Chodankar Avatar answered Sep 23 '22 06:09

Shamik Chodankar