News for hackers. Stuff that matters.
Re:Ask HN: How to handle user file uploads? by pier25 on Thursday May 02, 2024 @01:55AM (#40233120)
With Google Cloud Storage you can simply set a header with the max size allowed when signing the upload URL.
Re:Ask HN: How to handle user file uploads? by matusgallik008 on Thursday May 02, 2024 @03:37AM (#40233674)
I believe AWS S3 allows setting the Content-Length header as well. So you might not need the lambda
Re:Ask HN: How to handle user file uploads? by moomoo11 on Friday May 03, 2024 @01:49AM (#40244512)
Can you explain what you mean? I'm confused about the "might not need the lambda". Thanks!

In my case we allow up to 10mb file upload. For example just testing something right now from my iPhone I selected a 3.7mb image which was uploaded and resized to the "frame" it will go into in the UI and its now 288kb in S3. We have a few "frame" sizes which are consistent throughout our application. Now, my cloudfront is serving 288kb file instead of 3.7mb, which is good for me because I want to avoid the bandwidth costs and users honestly can't tell the difference, and then also we aren't a photo gallery app.

So in my case I need the lambda to resize the image to our "frame" sizes. I wonder if I didn't explain right. I'm ESL so just want to make sure since I'm confused about the your last sentence.

Re:Ask HN: How to handle user file uploads? by aprilnya on Friday May 03, 2024 @05:45AM (#40245835)
They mean you might not need the lambda if all you want to do is enforce a max size; if you want to do resizing/other processing then you’d still need the lambda
Re:Ask HN: How to handle user file uploads? by matusgallik008 on Friday May 03, 2024 @07:46AM (#40246553)
You're good mate. I meant exaclty what aprilnya said. I thought you are using the Lambda just to validate the 10mb limit - and just for that you don't need the lambda :) and could save yourself some cents & effort.

But if you do resizing as well, then ofc you need the Lambda (or some other compute engine).