can anybody help me? how to fix this.. the getdownloadurl() cannot resolve method
final String downloadUrl = task.getResult().getDownloadUrl().toString();
can anybody help me? how to fix this.. the getdownloadurl() cannot resolve method
final String downloadUrl = task.getResult().getDownloadUrl().toString();
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
}
});
}
}
It is no longer supported if your project is updated to the latest version. I had the same problem earlier, I tried many ways altering the same object. Instead I found out that firebase has changed the docs on their site and not in their Firebase Assistant. So, to save your time follow this link Firebase Upload Docs
and make necessary changes. It'll take 5 mins to change. If you want to confirm your problem with mine, here is the link My Problem
for me based on the answer from @JPDroid this is what worked
file_path.putFile(img_uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Object o) {
String download_url = o.toString();
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getActivity(), "Error in Upload !", Toast.LENGTH_LONG).show();
}
});