Тёмный

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

Nikita Dev
Подписаться 6 тыс.
Просмотров 10 тыс.
50% 1

In this video you'll learn how to create, modify, deploy, and test an AWS Lambda. I will show you how to set permissions through IAM roles/policies, and also how to set up S3 triggers to invoke your Lambda when an image is uploaded to a bucket. We will use the Sharp NPM package to easily resize images, and the AWS S3 SDK to interact with our buckets.
Code: github.com/OneLightWebDev/ima...
Sharp NPM: www.npmjs.com/package/sharp
Guide: docs.aws.amazon.com/lambda/la...
Github: github.com/nikitapryymak
Support Me: www.buymeacoffee.com/nikitadev
Contact Me: nikitadev292@gmail.com
#nodejs #aws #javascript

Наука

Опубликовано:

 

25 сен 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@cheey3839
@cheey3839 9 месяцев назад
Thank u!!! Yours is the most up to date tutorial, with details.
@ricksegalCanada
@ricksegalCanada 2 месяца назад
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.
@brunolaranjeira3855
@brunolaranjeira3855 7 месяцев назад
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.
@hmvarshney5222
@hmvarshney5222 Месяц назад
Great course! Simple and to-the-point, unlike others.
@vjself
@vjself 4 месяца назад
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 4 месяца назад
@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 Месяц назад
Did you found the solution... Im still stucked in it
@gianfrancoperaltabravo6004
@gianfrancoperaltabravo6004 9 дней назад
Amazing video !
@aleksey6151
@aleksey6151 9 месяцев назад
goated tutorial
@vvyael
@vvyael 5 месяцев назад
Amazing
@lucasfranzolin
@lucasfranzolin 11 дней назад
do you know why exactly I keep getting "sharp module not found"? I'm even zipping the node_modules
@sammunroe389
@sammunroe389 4 месяца назад
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 4 месяца назад
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 4 месяца назад
thanks for sharing!
@hashimali4262
@hashimali4262 6 месяцев назад
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 4 месяца назад
you would probably need to implement polling (on the bucket that stores resized images).
@WriteCodeWithMaan
@WriteCodeWithMaan 2 месяца назад
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 5 месяцев назад
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 4 месяца назад
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.
@sahebdhara1286
@sahebdhara1286 5 месяцев назад
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 4 месяца назад
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 4 месяца назад
Store the zip file in S3 bucket and provide the S3 object url in lambda upload
@regilearn2138
@regilearn2138 9 месяцев назад
can u show us how to save/upload image/multiple image in s3 bucket with lambda function in react app,
@nikita-dev
@nikita-dev 9 месяцев назад
I made a similar video to this already: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vVBqEYNXxy8.html
@ChadDiaz-qk4fb
@ChadDiaz-qk4fb 2 месяца назад
@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 2 месяца назад
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.
@tomscall3811
@tomscall3811 8 месяцев назад
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 4 месяца назад
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 4 месяца назад
@@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
@vikramadityasinghai5968
@vikramadityasinghai5968 8 месяцев назад
If i was to do this using python, which library could i use ???????/
@nikita-dev
@nikita-dev 4 месяца назад
Pillow is a popular python library for this
@harshal_joshi
@harshal_joshi Месяц назад
9:02 i have a error like zip' is not recognized as an internal or external command
@harshal_joshi
@harshal_joshi Месяц назад
Please reply me
@quanne131
@quanne131 6 месяцев назад
can you make i video about deploy nodejs app to aws free
@anirudh5101
@anirudh5101 3 месяца назад
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 3 месяца назад
maybe as part of a larger project, but not necessarily by itself. (just my opinion)
@anirudh5101
@anirudh5101 3 месяца назад
@@Benjamin-Chavez Thanks Benjamin 😄
@Kimitri
@Kimitri 7 месяцев назад
why use 2 separate buckets?
@nikita-dev
@nikita-dev 7 месяцев назад
mainly to avoid any chance of recursive invocations. if you go to 11:33 I talk a little bit about that.
@Kimitri
@Kimitri 7 месяцев назад
That makes sense. Thank you for replying to me.
@Kimitri
@Kimitri 7 месяцев назад
​@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?
@user-ov3iz5wv5v
@user-ov3iz5wv5v 9 месяцев назад
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 7 месяцев назад
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.
Далее
How to Use AWS S3 with NodeJS?
30:39
Просмотров 39 тыс.
Upload Images with React & Node JS  to AWS S3
42:18
Просмотров 18 тыс.
Beautiful gymnastics 😍☺️
00:15
Просмотров 7 млн
КРЫЛЬЯ - ЗЕНИТ: все голы
01:00
Просмотров 72 тыс.
ОСКАР И ДЖОНИ ПОДРАЛИСЬ 😳
01:00
Просмотров 313 тыс.
How to Run a Python Docker Image on AWS Lambda
13:08
Просмотров 27 тыс.
Storing Images in S3 from Node Server
39:59
Просмотров 84 тыс.
Brutally honest advice for new .NET Web Developers
7:19
AWS Lambda | Trigger on S3 file upload
9:17
Просмотров 10 тыс.
$1 vs $100,000 Slow Motion Camera!
0:44
Просмотров 24 млн