-1

Plzz help me to solve te problem. This is the line:

String thumb_download_url=thumb_task.getResult().getDownloadUrl().toString();

And the code is as below:

StorageReference filepath=mStorageReference.child("profile_image").child(uid+".jpg"); final StorageReference thumb_file_path=mStorageReference.child("profile_image").child("thumbs").child(uid+".jpg");

//------STORING IMAGE IN FIREBASE STORAGE--------
            filepath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
    @Override
    public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {

        if(task.isSuccessful()){

            @SuppressWarnings("VisibleForTests")
            final String downloadUrl=  task.getResult().getDownloadUrl().toString();
            UploadTask uploadTask = thumb_file_path.putBytes(thumb_bytes);

            //---------- STORING THUMB IMAGE INTO STORAGE REFERENCE --------
            uploadTask.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> thumb_task) {
                    @SuppressWarnings("VisibleForTests")
                    String thumb_download_url=thumb_task.getResult().getDownloadUrl().toString();
                    if(thumb_task.isSuccessful()){
                        Map update_HashMap=new HashMap();
                        update_HashMap.put("image",downloadUrl);
                        update_HashMap.put("thumb_image",thumb_download_url);

                        //--------ADDING URL INTO DATABASE REFERENCE--------
                        mDatabaseReference.updateChildren(update_HashMap).addOnCompleteListener(new OnCompleteListener<Void>() {
                            @Override
                            public void onComplete(@NonNull Task<Void> task) {

                                if(task.isSuccessful()){
                                    mProgressDialog.dismiss();
                                    Toast.makeText(SettingActivity.this, "Uploaded Successfuly...", Toast.LENGTH_SHORT).show();

                                }
                                else{
                                    mProgressDialog.dismiss();
                                    Toast.makeText(getApplicationContext(), " Image is not uploading...", Toast.LENGTH_SHORT).show();

                                }

                            }
                        });

                    }
                    else{
                        mProgressDialog.dismiss();
                        Toast.makeText(getApplicationContext(), " Error in uploading Thumbnail..", Toast.LENGTH_SHORT).show();
                    }
                }
            });
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193

1 Answers1

1

You get the following error in Android Studio:

cannot find symbol method getDownloadUrl()

Because when you call getResult() method on the thumb_task object, the type of object that is returned is UploadTask.TaskSnapshot and as you can see there no getDownloadUrl() method in this class, hence the error. To get the download url in a correct way, please see my answer from the following post:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193