Issues filed here should be about a feature request for a specific extension in this repository. To file a feature request that affects multiple extensions or the Firebase Extensions platform, please reach out to
Firebase support directly.
storage-resize-images
Add an option to not just delete the original image, but completely replace it by the resized image.
1) Upload a new image to the storage
2) Store the download url in a document and display the original image in frontend
3) Extension is triggered and creates the resized image
4) Resized image overwrites orginal image (same file-name)
5) Now the resized image should be automatically displayed in the future, since it should have the same download url
Allow me to correct you on point 5:
Now the resized image should be automatically displayed in the future, since it should have the same download url
It won't have the same url, since those are generated using tokens meant to be unique and revocable. In Cloud Storage, once an image is replaced with another one with the same name, the download URL will be different.
I´m currently running tests where I upload a new image that has the same file-name as the previous one (so overwriting it) without updating the download-url in my Firestore document and the new one is still displayed correctly.
Maybe this way is not a good practice, but apparently the download-url doesn´t change enough that it wouldn´t fit the newly uploaded image file.
@RegniBlef I see... I'll investigate further, thanks for mentioning that.
@rosariopfernandes As you said, the "media&token" changes, but still both download-urls work fine and show the new image.
Firestore (old link):
https://xxx/o/users%2FFtr5JeM7pNTTDu1ptNGKAarkOa23%2Favatar?alt=media&token=22db8bbf-ae76-49d7-aa61-0aa1d398a4e8
Storage (new link):
https://xxx/o/users%2FFtr5JeM7pNTTDu1ptNGKAarkOa23%2Favatar?alt=media&token=58b10809-3a18-459f-a4c5-584ae885ad5c
That's great! I thought the previous token would be revoked... I like this suggestion, btw.
Seems like a reasonable feature request. Thanks for raising it.
As you said, the "media&token" changes, but still both download-urls work fine and show the new image.
Are you sure your files are not publicly accessible (i.e. that any token would work)? The download token should be replaced when you overwrite the file, and the old token isn't kept, which makes the old download URL invalid. I just confirmed this using both the Firebase Console and the Firebase Storage SDK.
@nicoqh You are probably right about this, I never looked at the accessibility of my images since I´ve only created public projects up until now. But I still think this feature would be a nice addition, the problem you stated could be handled by a checkbox labelled „replace original image“ and a hint saying „new image won´t be accessible with old media-token if not publicly accessible“.
Also I believe most of the people that are using this extension are using it in a public context, for example, to resize/compress profile pictures of users.
@RegniBlef I agree that it would be a nice addition! My proposal in #323 could accommodate this feature without requiring that the files are public.
Thanks for the feedback everyone! We considered this and tried think of robust ways to support it but unfortunately, felt that it would add too much complexity at this point. Thanks again for the great feedback and sample use cases.
Most helpful comment
Seems like a reasonable feature request. Thanks for raising it.