0

I am trying to create an application firebase image upload.

hay buddy, I have some issue in image download URL getting a session.

my firebase version is :

implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'

and my download URL getting code is :

String profileimageurl = taskSnapshot.getMetadata().getReference().getDownloadUrl().toString();

How to solve this problem and my error is :

java.io.FileNotFoundException: /com.google.android.gms.tasks.zzu@527ce2f (No such file or directory)
I/Glide: Root cause (2 of 3)
    java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
I/Glide: Root cause (3 of 3)
    java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)

The image is uploaded in my firebase storage but it can't accessible

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Thangapandi
  • 208
  • 2
  • 15

1 Answers1

1

Finally,

 private void uriImageUpload() {
        final StorageReference storageReference = FirebaseStorage.getInstance().getReference("myprofile/" + System.currentTimeMillis() + ".jpg");
        if (urimageurl != null) {
            storageReference.putFile(urimageurl)
                    .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            Toast.makeText(getApplicationContext(), "Image Uploaded Successfully", Toast.LENGTH_LONG).show();

                            //TODO Here is the problem
//                            profileimageurl = taskSnapshot.getDownloadUrl().toString();
                            String myprofileurl  = taskSnapshot.getMetadata().getReference().getDownloadUrl().toString();
                            Log.d(TAG, "Profile image uploading url " + myprofileurl);

                            storageReference.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                                @Override
                                public void onComplete(@NonNull Task<Uri> task) {
                                    profileimageurl=task.getResult().toString();
                                    Log.i("URL",profileimageurl);
                                }
                            });

                        }
                    }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(getApplicationContext(), "Image Uploading was failed", Toast.LENGTH_LONG).show();
                }
            });
        }
    }

just Adding the

storageReference.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                                    @Override
                                    public void onComplete(@NonNull Task<Uri> task) {
                                        profileimageurl=task.getResult().toString();
                                        Log.i("URL",profileimageurl);
                                    }
                                });

Thats all.

Thangapandi
  • 208
  • 2
  • 15