简体   繁体   English

使用Aws Lambda将映像上传到AWS S3存储桶

[英]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. 我想对使用Lambda函数在S3存储桶中上传图像文件提出一些建议。我能够使用Lambda函数创建存储桶,但无法使用Lambda函数将文件上传到S3。 It is possible? 有可能的? can we upload local system files(image,text etc) files to S3 bucket using lambda?. 我们可以使用lambda将本地系统文件(图像,文本等)文件上传到S3存储桶吗?

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'. 当我尝试使用Lambda函数将使用C:\\ users \\ images.jpg的文件上传到S3时,向我显示错误..E​​rror:ENOENT,没有此类文件或目录'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. 如果您有桌面应用程序,则可以访问本地文件,例如C:\\ users \\ images.jpg,因为该进程可以访问文件系统。

Your lambda functions are maintained by AWS and they run on Amazon's infrastructure. 您的lambda函数由AWS维护,它们在Amazon的基础架构上运行。

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. 本地文件系统访问,子进程和类似工件可能不会超出请求的生存期,并且任何持久状态都应存储在Amazon S3,Amazon DynamoDB或其他Internet可用的存储服务中。

Reference: AWS Lambda FAQs 参考: AWS Lambda常见问题解答

So in your case I'd upload everything to S3 first, or create a background process that does this periodically. 因此,在您的情况下,我首先将所有内容上传到S3,或者创建一个定期执行此操作的后台进程。 That way you can access them via Lambda functions but not directly from your local file system. 这样,您可以通过Lambda函数访问它们,但不能直接从本地文件系统访问它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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