简体   繁体   中英

Upload Image into AWS S3 bucket using Aws Lambda

I want some suggestion on Upload Image file in S3 bucket using Lambda function.I am able to create bucket using lambda function but unable to upload file to S3 using Lambda function. It is possible? can we upload local system files(image,text etc) files to S3 bucket using lambda?.

when I am trying upload file using C:\\users\\images.jpg to S3 using Lambda function its showing me error ..Error: ENOENT, no such file or directory 'C:\\Users\\Images'.

Please suggest.

Thanks

You have to imagine where your code is running.

If you have a desktop application, you can access to local files such as C:\\users\\images.jpg becasue the process is has access to the file system.

Your lambda functions are maintained by AWS and they run on Amazon's infrastructure.

Also in general you have to design your functions stateless:

Local file system access, child processes, and similar artifacts may not extend beyond the lifetime of the request, and any persistent state should be stored in Amazon S3, Amazon DynamoDB, or another Internet-available storage service.

Reference: AWS Lambda FAQs

So in your case I'd upload everything to S3 first, or create a background process that does this periodically. That way you can access them via Lambda functions but not directly from your local file system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM