StorageReference filePath = employee_photo_profile_reference.child(current_employee_ID+".jpg");
filePath.putFile(result_uri).addOnCompleteListener( new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()){
Toast.makeText(activity_setup.this,"Profile Photo stored Successfully.", Toast.LENGTH_SHORT).show();
if (task.getResult() != null){
final String download_url = task.getResult().getStorage().getDownloadUrl().toString();
Asked
Active
Viewed 96 times
-1

Doug Stevenson
- 297,357
- 32
- 422
- 441

Alice Dias
- 1
- 2
-
this will give you a `link` to download/get the file you just uploaded. you should upload it to `firestore` so you can easily access it again, if it is a profile picture you should add this to the user document, you can load image from this like via any image loading lib – Rahul Gaur Feb 08 '20 at 18:08
-
1@RahulGaur Actually, it's not doing that. It's an incorrect use of getDownloadURL. – Doug Stevenson Feb 08 '20 at 18:11
1 Answers
1
That line of code is buggy. It's incorrectly using getDownloadUrl()
. This is a very common mistake - you can't just call toString()
on the result to get a URL.
getDownloadUrl() returns a Task object which you can use to fetch the download URL asynchronously.
The correct usage is demonstrated here: How to get URL from Firebase Storage getDownloadURL
I also suggested reading the documentation.

Doug Stevenson
- 297,357
- 32
- 422
- 441