FabricioG
FabricioG

Reputation: 3320

Firebase is not pulling up img with getDownloadURL

I currently have this item (one as an example but there are more)

Luke-Muñiz.jpg

I see it in gs://example.com/images/ then I make a call to firebase like so:

props.firebase.storageRef(`images/${props.data.profilePic}`).getDownloadURL().then(url => {
      setImgRef(url);

When I do the above I get a 403 error.

FirebaseStorageError {code_: "storage/object-not-found", message_: "Firebase Storage: Object 'images/Luke-Muñiz.jpg' does not exist.", serverResponse_: "{↵  "error": {↵    "code": 404,↵    "message": "No…not get object",↵    "status": "GET_OBJECT"↵  }↵}", name_: "FirebaseError"}

Then of course GET url gives a 404

https://firebasestorage.googleapis.com/v0/b/example-bda7b.appspot.com/o/images%2FLuke-Mu%C3%B1iz.jpg 

My rules for storage are:

1
rules_version = '2';
2
service firebase.storage {
3
  match /b/{bucket}/o {
4
    match /{allPaths=**} {
5
      allow read, write: if request.auth != null;
6
    }
7
  }
8
}
9
​

I can confirm I'm logged in since I can view some of the images. Any idea what I'm doing wrong?

Upvotes: 0

Views: 53

Answers (1)

Stratubas
Stratubas

Reputation: 3067

Maybe that ñ is confusing (see snippet). Try to encodeURI your props.data.profilePic.

const name = 'Muñiz'; // copied from question
const encoded = encodeURI(name);
console.log(encoded);
const decoded = decodeURI(encoded);
console.log(decoded);
const yours = decodeURI('Mu%C3%B1iz'); // copied from question
console.log(yours);

Upvotes: 2

Related Questions