Upload Image into AWS S3 bucket using Aws Lambda

大兔子大兔子 提交于 2019-12-11 09:58:22

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/35219390/upload-image-into-aws-s3-bucket-using-aws-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!