0

can anybody help me? how to fix this.. the getdownloadurl() cannot resolve method

final String downloadUrl = task.getResult().getDownloadUrl().toString();

3 Answers3

3

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
                                }
                            });
        }
    }   
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
JPDroid
  • 46
  • 3
0

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

Karan
  • 370
  • 1
  • 3
  • 15
0

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();
                }
            });
Wowo Ot
  • 1,362
  • 13
  • 21