StorageException has occurred. Object does not exist at location. Storage FireBase
Asked Answered
I

11

18

I want display image in imageView, that's what I'm doing: I'm using FirebaseUI to display images from FireBase Storage.

FirebaseStorage storageDisplayImg;
StorageReference storageRef;
private FirebaseAuth auth;



        storageDisplayImg=FirebaseStorage.getInstance();
        auth = FirebaseAuth.getInstance();
        FirebaseUser userConnect = auth.getCurrentUser();
        String id_user=userConnect.getUid();
        storageRef = storageDisplayImg.getReference().child(item.getChemin_image()); // return gs://mydreambook-32321.appspot.com/images/test23-03-2017_16:46:55

        if (item.getChemin_image() != null&&id_user != null) {

           Glide.with(convertView.getContext() )
                   .using(new FirebaseImageLoader())
                   .load(storageRef)
                   .into(profilePic);
            profilePic.setVisibility(View.VISIBLE);

        } else {
            profilePic.setVisibility(View.GONE);
        }

But I have this error:

StorageException has occurred.  Object does not exist at location.    Code: -13010 HttpResult: 404

Update , Image in storage FireBase

enter image description here

Impertinent answered 23/3, 2017 at 16:45 Comment(4)
Use the Firebase Console to confirm there is an image stored at location gs://myApp.appspot.com/images/sport23-03-2017_15:22:54Energetics
Please check the Update @BobSnyderImpertinent
Does item.getChemin_image() return the full string "gs://myApp.appspot.com/images/sport23-03-2017_15:22:54" or does it only return "images/sport23-03-2017_15:22:54"? If it returns the former you actually want to do storageDisplayImg.getReferenceFromUrl(item.getChemin_image()) (which takes the full URL).Rodriguez
it works , thanks @MikeMcDonaldImpertinent
L
7

I had the same problem right now and I realized that my image in storage ends with .jpg but my code is asking for the address that ends with .png. After I fixed that, it ran perfectly for me.

Labyrinthodont answered 15/11, 2018 at 18:51 Comment(0)
P
4

You can simply show the image in two ways using Glide method. If we want to access below method, we must change the Firebase Storage Rules. Here I included my rules.

service firebase.storage {
  match /b/project-id.appspot.com/o {
    match /{allPaths=**} {
      allow write: if request.auth != null;
      // or allow write: if true;
    }
  }
} 

Method 1. Simply use the Firebase Reference

FirebaseStorage storage = FirebaseStorage.getInstance();
                StorageReference storageRef = storage.getReferenceFromUrl("gs://your-id.appspot.com");
                StorageReference pathReference = storageRef.child("images/cross.png");

                Glide.with(context)
                        .using(new FirebaseImageLoader())
                        .load(pathReference)
                        .into(Imageview)

Method 2. Firebase URL

     Glide.with(context)
             .using(new FirebaseImageLoader())
             .load("Firebase_ImageURL")
             .into(Imageview)
Pianissimo answered 23/3, 2017 at 17:19 Comment(1)
Method 2 does not work. There is no "using" anymore in Glide.Occupation
M
3

hi i faced such problem two days ago. storage exception occurs normally to the projects which you created with google developer console prior to Firebase launch. so when i connected my app to existing project on Firebase it worked. to confirm whether your project accepts storage or not go to Firebase console and on left click storage if you were displayed with the file upload option there the project is capable of storage other wise not.

Matzo answered 8/4, 2017 at 4:14 Comment(1)
Please edit your comment in a readable form. It's very difficult to readRad
T
1

Okay i found solution when i got to know that i had to give complete path of an image

 storageReference.child("users").child(userID).child("screenshot")
                .child(imagePath).getFile(localFile)

enter image description here

And i was initially giving incomplete path

 storageReference.child("users").child(userID).child("screenshot").getFile(localFile)
              
Tunicate answered 6/4, 2021 at 11:21 Comment(0)
H
0

I had a similar problem. I was trying to delete a file with some wrong case letters

Example: Deleting file_of_user_uidabcde.png by searching for file_of_user_uIdAbCdE.png

Hardshell answered 17/2, 2020 at 14:23 Comment(0)
S
0

You can try to wait some time between the upload of the image and the recuperation of the image. That worked in my issue like this. Wish you a good luck.

Stigmatic answered 9/5, 2020 at 15:4 Comment(0)
J
0

In my case, I am saving the complete URL in the Firebase database and get it like this: gs: //your-id.appspot.com/images/cross.png

When I do this:

StorageReference ref = FirebaseStorage().Ref().Child(urlImag);
      url = (await ref.getDownloadURL()).toString();

I am doing the following:

StorageReference ref = FirebaseStorage (gs://your-id.appspot.com/images/cross.png).ref().child ();
      url = (await ref.getDownloadURL()).toString();

This step is not necessary if you already have the full URL saved in your field.

Janus answered 17/6, 2020 at 0:33 Comment(0)
S
0

I was using different Firebase project then I created new one. When I added google-services.json and trying to add photo in storage I occured this error. When I debuggin my project I occured that my storage ref showing old url (gs://oldproject.appspot.com). I searched appspot.com in Android project and seen values.xml file. Change values.xml file content with new firebase project id and then storage works.

Suanne answered 29/12, 2020 at 12:34 Comment(0)
B
0

Please check rule on storage if you get 404 error:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, create: if request.auth != null;
    }
  }
}
Brentbrenton answered 13/10, 2021 at 10:26 Comment(0)
P
0

I just check the type saved in my Firebase Storage.

So it automatically changed the type of my image from images/jpeg to webp.

This solution worked for me:

// Create file metadata including the content type
    StorageMetadata metadata = new StorageMetadata.Builder()
            .setContentType("image/jpeg")
            .build();


// Upload the file and metadata
    uploadTask = storageRef.child("images/mountains.jpg").putFile(file, 
    metadata);

check this https://firebase.google.com/docs/storage/android/upload-files#add_file_metadata

Platitude answered 1/12, 2022 at 16:54 Comment(0)
C
0

I had the same error. It was because I didn't set up firebase storage in my console. After I set up storage in the console it worked fine

Censor answered 9/1, 2024 at 11:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.