Comments (6)
It looks like this issue is caused when an image file is uploaded without an extension. The isResizedImage
should be be expanded to check for the extension, or the function should auto-assign an extension if missing, or as @Salakar mentioned a custom metadata field may be the best option.
Here is a test case for the current implementation. In prod, the result is an infinite loop that uploads resized images with an empty filename. This will cause runaway billing if not caught early.
const path = require('path')
const suffixRegex = /_\d+x\d+$/;
const isResizedImageValidator = (fileName) => suffixRegex.test(fileName);
const filePath = 'thumbs/someImageWithoutExt_200x200'
const fileName = path.basename(filePath);
const fileExtension = path.extname(filePath); // ""
const fileNameWithoutExtension = fileName.slice(0, -fileExtension.length); // ""
const isResizedImage = isResizedImageValidator(fileNameWithoutExtension);
console.log(isResizedImage) // false :(
from extensions.
Hey @marvinsxtr, looks like this is the regex failing here to pickup that it's already a resized image.
I think we can look at removing this regex and instead use a custom metadata field to infer that an image has already been resized.
from extensions.
The fix is now live in v.0.1.1 of the extension. You can update via Firebase Console or CLI by running:
firebase ext:update storage-resize-images --project <projectId>
@codediodeio If you would like to opt out of resizing some images, my suggestion would be to put those images inside of a different bucket. The reason is that if they are in the same bucket as the one that the extension is listening to, a Cloud Function will still be triggered. This will lead to higher quota usage and potential cost.
from extensions.
Hi @codediodeio what do you mean by "image file is uploaded without an extension"? I want to make sure our fix that is in flight is going to solve this issue, and i'm having trouble reproducing the issue in the first place.
@marvinsxtr can you tell me exactly what your installation parameters are? What did you put for "Cloud Storage path for resized images", and what is the format and name of the image you then uploaded? Was it uploaded to the root of the bucket or a sub folder, if so, what was the name of the sub folder? As much detail as possible would be appreciated. Thanks!
from extensions.
@laurenzlong Hello LaurenWiong, just stumbled upon the exact same issue.
Extension parameters:
Deployment location : europe-west2
Cloud Storage bucket for imagesDescription : comando-78b26.appspot.com
Sizes of resized imagesDescription : 300x300,600x450
Cloud Storage path for resized images (Optional): thumbnails
Cache-Control header for resized images (Optional): Parameter not set
Name of images set without the MYME type at the end like follow ("profile-USERID") :
const storageRef = storage().ref();
let storedProfileImageUrl = "";
let storedCoverImageUrl = "";
if (profilePicture && !typeof coverPicture === "string") {
const profileImageRef = storageRef.child(
`profile-${userID}.${profilePicture.type}`
);
const storedProfileImage = yield profileImageRef.put(profilePicture);
storedProfileImageUrl = yield storedProfileImage.ref.getDownloadURL();
}```
from extensions.
I mean when you upload a file like ref('my-image').put(img)
, where the file mime type is an image, but the path is missing .png
.
Setting a metadata property on the results, like use_resizer: false
is the best solution IMO. It has the added benefit of allowing developers to opt-out of the extension for specific files.
from extensions.
Related Issues (20)
- Typo in `README.md` for `storage-resize-images` extension
- 🐛 [firestore-bigquery-export] multi-db selection isn't working for Firestore triggers HOT 1
- time partition not working for firebase extension(0.1.49) HOT 4
- 🐛 [Stream Firestore to BigQuery] fs-bq-import-collection doesn't recognize partitioned field HOT 1
- 🐛 [Stream-Firestore-BigQuery] Import existing Firestore documents into BigQuery HOT 2
- 🐛 [firestore-send-email] Email status SUCCESS but not delivered
- [firestore-translate-text] Source text is translated from Latin and not English HOT 2
- firefox
- [firestore-send-email] Email templates stopped working yesterday. HOT 2
- 🐛 [Vector Search with Firestore] Error creating firestore Vector index. backfillTrigger() fail HOT 25
- 🐛 [firestore-vector-search] model: 'text-multilingual-embedding-002' HOT 1
- 🐛 Stream Firestore to BigQuery - disable changelog HOT 1
- 🐛 [storage-resize-images] Extension crops the image with default settings. HOT 2
- 🐛 [storage-resize-images] Console error when trying to use the extension HOT 1
- 🐛 [firestore-translate-text] Error on updating Extension
- 🐛 [EXTENSION_NAME_HERE] allow schedule email
- 🐛 [firestore-translate-text] can not translate array field HOT 1
- 🐛 [firestore-bigquery-export] Task size too large errors occuring even with EXCLUDE_OLD_DATA set to yes/true HOT 2
- 🐛 [firestore-bigquery-export] Unhandled error PartialFailureError HOT 2
- [firestore-send-email] Only works on (default) database HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extensions.