Resize Images with Node.js and AWS Lambda (and S3)

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 46

  • @ricksegalCanada
    @ricksegalCanada 6 หลายเดือนก่อน

    Thanks for taking the time to do this video. Your explanation style is excellent as all too often youtubers forget we don't know and they forget to explain things properly. Well done.

  • @cheey3839
    @cheey3839 ปีที่แล้ว +3

    Thank u!!! Yours is the most up to date tutorial, with details.

  • @devoptimist
    @devoptimist 28 วันที่ผ่านมา +1

    Great tutorial, thanks! AWS has since changed the layout of the console editor of Lambda functions, but it's still possible to change back to the old editor which let me compare with this video more directly. Also, when creating a Lambda function, it's no longer possible to directly create a Role / Policy because the "create policy" button is no longer there. However, I was able to create the specific policy as you recommended inside IAM and then find it when setting up the Lambda.

  • @vjself
    @vjself 9 หลายเดือนก่อน +1

    I couldn't actually get this to work following your video (sharp really does have some issues running in lambda) but cloning your repo and adjusting the code to my needs did the trick. Thank you so much for this it was incredibly helpful!

    • @DeveloperDsb
      @DeveloperDsb 8 หลายเดือนก่อน

      @vjself did you created your own function.zip file? if yes, could you please tell me how u did this because I tried to do so by running the command npm run package but I am getting the error "PS C:\Users\Dell\Desktop\Lambda_function\image-resizer-lambda> npm run package
      > thumbnail-generator-lambda@1.0.0 package
      > zip -r function.zip .
      'zip' is not recognized as an internal or external command,
      operable program or batch file."

    • @R.Yuvashri
      @R.Yuvashri 5 หลายเดือนก่อน

      Did you found the solution... Im still stucked in it

  • @hmvarshney5222
    @hmvarshney5222 6 หลายเดือนก่อน

    Great course! Simple and to-the-point, unlike others.

  • @brunolaranjeira3855
    @brunolaranjeira3855 ปีที่แล้ว

    Amazing work my friend. Your code worked like a charm. Only thing I changed was to hardcode the destination Bucket instead of using ENV variables. Thank you from Brazil.

  • @sammunroe389
    @sammunroe389 9 หลายเดือนก่อน +2

    Great tutorial. I am running into one snag. Whenever I extract the function zip, modify index.js to 400px instead of 200px, re-zip, and upload....it tells me it can't find module 'index'

    • @sammunroe389
      @sammunroe389 9 หลายเดือนก่อน +2

      Figured it out! Don't zip the functions parent folder. Select all files and zip, to a new zipped folder. Very strange but it fixed it.

    • @nikita-dev
      @nikita-dev  9 หลายเดือนก่อน

      thanks for sharing!

  • @aleksey6151
    @aleksey6151 ปีที่แล้ว +3

    goated tutorial

  • @Adityabalaji-qv4nx
    @Adityabalaji-qv4nx 2 หลายเดือนก่อน

    Excellant training sir

  • @sahebdhara1286
    @sahebdhara1286 9 หลายเดือนก่อน +2

    The deployment package of your Lambda function "lamda-for-image-resize" is too large to enable inline code editing. However, you can still invoke your function.

    • @alexander_ci
      @alexander_ci 8 หลายเดือนก่อน +2

      One way around this is using a Lambda layer and pointing your dependencies to that Layer, then that normally makes it a much smaller package.

    • @vigneshtamizh4091
      @vigneshtamizh4091 8 หลายเดือนก่อน +1

      Store the zip file in S3 bucket and provide the S3 object url in lambda upload

  • @gianfrancoperaltabravo6004
    @gianfrancoperaltabravo6004 4 หลายเดือนก่อน

    Amazing video !

  • @ChadDiaz-qk4fb
    @ChadDiaz-qk4fb 6 หลายเดือนก่อน +1

    @nikita-dev - I'd like to set something like this up but will take an original image and output a web image, mobile image and thumbnail image. Can you assist how to do this?

    • @nikita-dev
      @nikita-dev  6 หลายเดือนก่อน +1

      After you fetch the original image in S3, you need to run the Sharp resize function 3 times, passing in your desired widths for web, mobile & thumbnail. Then you’ll need to save off those 3 images in your output bucket, with their sizes included in the key.

  • @lucasfranzolin
    @lucasfranzolin 4 หลายเดือนก่อน

    do you know why exactly I keep getting "sharp module not found"? I'm even zipping the node_modules

  • @WriteCodeWithMaan
    @WriteCodeWithMaan 6 หลายเดือนก่อน

    How can we access the sharp library without adding any dependency or without adding any layer to lambda? How your lambda function is reading the sharp library?

  • @Matt6176
    @Matt6176 9 หลายเดือนก่อน

    Hello and thank you for this tutorial! Could you please explain what the purpose of the package-lock.josn file is? Will the function run without it? Thank you!

    • @nikita-dev
      @nikita-dev  9 หลายเดือนก่อน

      The package-lock file just stores the versions of all of the dependencies in your package json at the point of installation. I would not recommend removing this file.

  • @hashimali4262
    @hashimali4262 10 หลายเดือนก่อน

    Great work.
    Ok I have a question when we upload image from frontend via post request it get stored in s2 and lambda function get triggered and image converted and stored to another s3 bucket.
    Now I want to send the converted image back as response to the user how I may able to do it?
    as my flask python coed will not wait for the completing of conversion in lambda

    • @nikita-dev
      @nikita-dev  9 หลายเดือนก่อน

      you would probably need to implement polling (on the bucket that stores resized images).

  • @vvyael
    @vvyael 9 หลายเดือนก่อน

    Amazing

  • @tomscall3811
    @tomscall3811 ปีที่แล้ว

    So that's it with the Lambda code :). I have the feeling that I have to rewrite my whole app just to make it run on Lambda. Or is there an easy way? I use multer-sharp-s3 in my app, where everything is stored in an S3 bucket. Everything works great locally. But there are problems on Lambda. How can I get it to run. What additional code do I need for Lambda?

    • @nikita-dev
      @nikita-dev  9 หลายเดือนก่อน

      It might be a permissions error (make sure the lambda has access to the right buckets). Also check the lambda logs for specific errors

    • @tomscall3811
      @tomscall3811 9 หลายเดือนก่อน +1

      @@nikita-dev Thank you very much. I didn't understand the function of Lambda back then. I wanted to publish an entire app, which led to problems. I then switched to Elastic Beanstalk

  • @regilearn2138
    @regilearn2138 ปีที่แล้ว

    can u show us how to save/upload image/multiple image in s3 bucket with lambda function in react app,

    • @nikita-dev
      @nikita-dev  ปีที่แล้ว

      I made a similar video to this already: th-cam.com/video/vVBqEYNXxy8/w-d-xo.html

  • @harshal_joshi
    @harshal_joshi 6 หลายเดือนก่อน

    9:02
    i have a error like zip' is not recognized as an internal or external command

    • @harshal_joshi
      @harshal_joshi 6 หลายเดือนก่อน

      Please reply me

  • @anirudh5101
    @anirudh5101 8 หลายเดือนก่อน

    Can anyone tell me is this project worth putting In my resume. Im just a beginner and pursuing my masters right now

    • @Benjamin-Chavez
      @Benjamin-Chavez 7 หลายเดือนก่อน +1

      maybe as part of a larger project, but not necessarily by itself. (just my opinion)

    • @anirudh5101
      @anirudh5101 7 หลายเดือนก่อน

      @@Benjamin-Chavez Thanks Benjamin 😄

  • @vikramadityasinghai5968
    @vikramadityasinghai5968 ปีที่แล้ว

    If i was to do this using python, which library could i use ???????/

    • @nikita-dev
      @nikita-dev  9 หลายเดือนก่อน

      Pillow is a popular python library for this

  • @Kimitri
    @Kimitri ปีที่แล้ว

    why use 2 separate buckets?

    • @nikita-dev
      @nikita-dev  ปีที่แล้ว +1

      mainly to avoid any chance of recursive invocations. if you go to 11:33 I talk a little bit about that.

    • @Kimitri
      @Kimitri ปีที่แล้ว

      That makes sense. Thank you for replying to me.

    • @Kimitri
      @Kimitri ปีที่แล้ว

      ​@nikita-dev I have another question, my application is for an photo studio, and the employees gonna upload more than 1000 photos for each album. The select all the photos and click in upload, I need to do some configuration on lambda function to works with it with no problems?

    • @devoptimist
      @devoptimist 28 วันที่ผ่านมา

      @@Kimitri Hi, I'm just curious if you were able to get that working. Since users can select and upload so many images at one time, was the Lambda function able to queue them and handle in the background or did it fail?

  • @quanne131
    @quanne131 10 หลายเดือนก่อน

    can you make i video about deploy nodejs app to aws free

  • @MaryamArshad-k2s
    @MaryamArshad-k2s ปีที่แล้ว

    Hi!
    When i test the event i got error as
    Response
    {
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'index'
    Require stack:
    - /var/runtime/index.mjs",
    "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module 'index'",
    "Require stack:",
    "- /var/runtime/index.mjs",
    " at _loadUserApp (file:///var/runtime/index.mjs:1087:17)",
    " at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
    " at async start (file:///var/runtime/index.mjs:1282:23)",
    " at async file:///var/runtime/index.mjs:1288:1"
    ]
    }

    • @rassdsign8788
      @rassdsign8788 11 หลายเดือนก่อน

      Hi the reason you got that error is because you zip the folder instead you should directly zip the file so that when you open zip file it directly can read index.js.