Reputation: 994
I'm using the Firebase Resize Images extension to create 120x120 thumbnails for content, keeping the original images. I was hoping to be able to just store the original full size downloadUrl
on my content and do a downloadUrl.replace('.png', '_120x120.png')
whenever I want to display a thumbnail. Who wants to store 2 different image urls on every piece of content?
So, I configured the extension to "Make resized images public", but the resized images still require a token and it's a different token from the original image, so I can't just get the thumbnail by adding the size params to the original downloadUrl
. If I do, I get a 403 since the tokens are different.
If resized images still require a token, I'm not sure what it means to "Make resized images public". Any guidance? This seems like it would be a pretty common use case, so maybe I'm missing something.
Upvotes: 0
Views: 1148
Reputation: 994
Another solution is to modify the source code of the extension to disable the generation of a new token. Similar process described here: Avoid re-generating token when using Firebase Image Resize Extension, but line numbers are updated for Dec '22
ext-storage-resize-images-generateResizedImage
function/lib/resize-image.js
if (metadata.metadata.firebaseStorageDownloadTokens) {
metadata.metadata.firebaseStorageDownloadTokens = uuidv4_1.uuid();
}
if (metadata.metadata.firebaseStorageDownloadTokens) {
// metadata.metadata.firebaseStorageDownloadTokens = uuidv4_1.uuid();
}
NOTE: If you modify the Resize Images extension configuration in the Firebase Console after doing this, it will overwrite your changes, so you'll need to follow this process again.
Upvotes: 0
Reputation: 26296
Making a file public allows you to skip using download URLs, which are signed with access tokens that expire.
Instead, you can access files using their public URI, which is of the format:
https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME
So for one of your thumbnails, you use something similar to the following URI:
https://storage.googleapis.com/my-project-id.appspot.com/userImages/NT672kMZu5c1kijkAmsoqRUDivC3/profile_120x120.png
Upvotes: 2