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(); } });
Is it possible to get this URL which is shown in image?
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.
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.
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.
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.
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 } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With