Error: Cannot Find Symbol Method Getdownloadurl() of Type Com.Google.Firebase.Storage.Uploadtask.Tasksnapshot

Cannot resolve taskSnapshot.getDownloadUrl() in android firebase

Try this implementation. Use continueWithTask to get the downloaded url.

final UploadTask uploadTask = filepath.putFile(uri);   
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

uploadTask.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();

}
// Continue with the task to get the download URL
return filepath.getDownloadUrl();

}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
thumb_download_url = task.getResult().toString();

}
}
});

}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});

Cannot resolve getDownloadUrl() Firebase

Try to:

storageReference.child("YOUR_CHILD")
.putFile("FILE")
.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
taskSnapshot
.getStorage()
.getDownloadUrl()
.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Uri uri) {
//Put your result here
}
});
}
}

Firebase Storage getDownloadUrl() method can't be resolved

The Firebase API has changed.

May 23, 2018

Cloud Storage version 16.0.1

Removed the deprecated StorageMetadata.getDownloadUrl() and UploadTask.TaskSnapshot.getDownloadUrl() methods. To get a current download URL, use StorageReference.getDownloadUr().

UploadTask.TaskSnapshot has a method named getMetadata() which returns a StorageMetadata object.

This StorageMetadata object contains a method named getReference() which returns a StorageReference object.

That StorageReference object contains the getDownloadUrl() method, which now returns a Task object instead of an Uri object.

This Task must then be listened upon in order to obtain the Uri, which can be done asynchronously or in a blocking manner; see the Tasks API for that.

Error: cannot find symbol Upload upload = new Upload(editTextName.getText().toString().trim(), taskSnapshot.getDownloadUrl().toString());

 taskSnapshot.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
File file = new File(uri.getPath());
Upload upload = new Upload(editTextName.getText().toString().trim(), file.getPath());
}
});

taskSnapshot.getDownloadUrl() method not working

Edit: see this comment on why the approach in this answer doesn't work:

firebaser here This answer is wrong. While it at first may appear to work (since it compiles) the result of getDownloadUrl().toString() is not a download URL, but a string representation of a Task object. For a better answer, see stackoverflow.com/a/55503926 or the sample in the Firebase documentation.

Original answer below...


In Firebase Storage API version 16.0.1,
the getDownloadUrl() method using taskSnapshot object has changed.
now you can use,

taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()

to get download url from the firebase storage.



Related Topics



Leave a reply



Submit