I upload all my users profile photos in this path:
const userUploadRef = ref(
storage,
`profilePhotos/${user.data?.uid}`
);
I currently access the url like this:
getDownloadURL(uploadTask.snapshot.ref).then(async (downloadUrl) => {
if (user.data?.uid) {
setDownloadURL(downloadUrl);
However, I just realized that even though the path is always going to be the same, each picture has a different url?
This causes massive issues - if I want to attach this user photo to something like comments, posts or any other content, I will have to make sure that the user profile image url is updated.
Surely there must be a way that I can reuse the same url since the path to the user profile photo is always going to be the same regardless?
Edit:
I have tried following this guide - https://www.sentinelstand.com/article/guide-to-firebase-storage-download-urls-tokens on how to remove the token and make my file public, but firebase keeps adding the token regardless.
if (folder == "profilePhotos" && isThumbnail) {
const [newFile]: any = file.makePublic();
const [metadata] = newFile.getMetadata();
const url = metadata.mediaLink;
const userPublicRef = db.collection("usersPublic").doc(userId);
const usersPrivateRef = db.collection("users").doc(userId);