Home > Software engineering >  Get the correct download url in firebase storage
Get the correct download url in firebase storage

Time:07-31

I have a folder inside my firebase storage named 'banners' Using javascript I have successfully uploaded it to the folder. The problem is that the URL provided by the getDownloadURL() is giving me an error 'Invalid HTTP method/URL pair'

The link below is the one provided by the getDownloadURL() method, which does not work. https://firebasestorage.googleapis.com/v0/b/sample.appspot.com/o/banners/imageid123.jpg?alt=media&token=sampletoken

And this is the link that is working https://firebasestorage.googleapis.com/v0/b/sample.appspot.com/o/banners/imageid123.jpg?alt=media&token=sampletoken

I noticed that it works when there is a / in the link, but I don't know how it will generate a link in that format.

I hope you can help me. Thank you

CodePudding user response:

Firebase storage stores all files in the root of each bucket. Files inside folders are just normal files having prefixes in their names. For example: Banners/123.jpg is a single file in the root with that string as its whole name.

This is the reason that you need to encode all inner slashes with / in your download URLs. Whether you use the API to get them or generate them manually for public files.

CodePudding user response:

Without looking into your code how are we gonna suggest?

However, Check the method Here.

  • Related