I am using Firebase storage, and in documentation, I see the method getDownloadURL(), but all it does is attaches some token at the end of the URL?
If my pictures are public, can I simply create the download link myself using a template literal and store it in the Firestore without the token?:
so instead of this:
getDownloadURL(userUploadRef).then(async (downloadUrl) => {
const imageUrl = downloadUrl;
// store it to firestore
simply do this:
const imageUrl = `https://firebasestorage.googleapis.com/v0/b/myapp.appspot.com/o/routinePhotos%2F${res.data.docRefId}?alt=media`;
const thumbnailUrl = `https://firebasestorage.googleapis.com/v0/b/myapp.appspot.com/o/routinePhotos%2F${res.data.docRefId}_640x360?alt=media`;
// store links in firestore
Because these links are based on the document Id in the Firestore, even if I change the actual picture in the storage, I wouldn't have to update the link in the Firestore document, since these links will always refer to the same location.
- Can I create a link myself?
- What is the purpose of the
getDownloadUrl()? - What is the need for the extra token URL at the end of the link, If I can access that file without it anyways?