Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-image files are still read #79

Open
SansPapyrus683 opened this issue Mar 1, 2024 · 2 comments
Open

Non-image files are still read #79

SansPapyrus683 opened this issue Mar 1, 2024 · 2 comments

Comments

@SansPapyrus683
Copy link

Hi!

I was using the compress utility of this library when I found that this function tries to read any uploaded file, not just image files.
This results in error messages being produced like the following:
image

A simple fix would be as follows in serverless-galleria-util/index.js, but I'm not sure if it would mesh with the other utilities:

      const rawKey = record.s3.object.key;
      const ext = rawKey.split(".").pop();
      const goodTypes = ["jpeg", "jpg", "png"];
      if (!goodTypes.includes(ext)) {
        console.log(`Skipping ${rawKey} as its file extension ${ext} is unsupported`)
        return;
      }
@evanchiu
Copy link
Owner

Hello @SansPapyrus683!

It looks like jimp has a clear listing of the file types that it supports, so I could probably check the mime type of the file before reading it to confirm that it’s supported.

The thing is, that this set of libraries are focused on building an image processing pipeline. So my expectation is that users are putting images in. If they put in something that’s not an image, the first lambda to pick it up will crash and the file won’t be propagated into the next bucket. Adding something like this gives a possibly clearer error message, but the processing result is the same.

What problem are you hoping for me to solve here?

@SansPapyrus683
Copy link
Author

Hi, and thanks for the reply!

Adding something like this gives a possibly clearer error message

This is the main thing I'm looking for, but I completely understand if such code is deemed unnecessary. My issue was that AWS put some auxiliary stuff regarding cost metrics in the S3 bucket along with images, and the pipeline still tried to transform these .csv files and whatnot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants