I have a firebase resize images extension that once the image uploaded to a specific folders(profilePhotos in my case) it converts that image to smaller size(320x320 in my case) and just adds "_320x320" to the end of the name.
Initially, I had a cloud function creating urls and updating the correlating document in firestore via getSignedUrl() until I realised that all signed urls expire after 7 days.
This is how I get the original pictures download url from the front end:
uploadTask.on(
"state_changed",
(snapshot) => {
const progress =
(snapshot.bytesTransferred / snapshot.totalBytes) * 100;
setProgress(progress);
},
(error) => {
console.log("error" + error);
},
() => {
getDownloadURL(userUploadRef).then(async (downloadUrl) => {
// code that updates the document in firestore by adding the url
If I know that the only difference between the original and resized image name is that one ends with _320x320, can I just alter the download url to get the download url of my image, if so how can it be done?
Changing the download URL would only work if the access token is passed on from the original image to the resized image, which I'm not sure if it is (the Extension supported that at some point, but I recall there were issues with it).
The better approach would be to determine the download URL for the resized image name by a separate call to getDownloadURL with a reference to the correct path:
const storage = getStorage();
const resizedRef = ref(storage, 'images/stars_320x320.jpg');
getDownloadURL(resizedRef).then(...