使用Aws Lambda将映像上传到AWS S3存储桶 [英] Upload Image into AWS S3 bucket using Aws Lambda

查看:268
本文介绍了使用Aws Lambda将映像上传到AWS S3存储桶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对使用Lambda函数在S3存储桶中上传图像文件提出一些建议.我能够使用Lambda函数创建存储桶,但无法使用Lambda函数将文件上传到S3.有可能的?我们可以使用lambda将本地系统文件(图像,文本等)文件上传到S3存储桶吗?

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?.

当我尝试使用Lambda函数使用C:\ users \ images.jpg将文件上传到S3时,向我显示错误..E​​rror:ENOENT,没有这样的文件或目录'C:\ Users \ Images'.

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'.

请提出建议.

谢谢

推荐答案

您必须想象代码在哪里运行.

You have to imagine where your code is running.

如果您有桌面应用程序,则可以访问本地文件,例如C:\ users \ images.jpg,因为该进程可以访问文件系统.

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.

您的lambda函数由AWS维护,并在Amazon的基础架构上运行.

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

通常,您还必须设计无状态的函数:

Also in general you have to design your functions stateless:

本地文件系统访问,子进程和类似工件可能 不会超出请求的生命周期,并且任何持久性 状态应存储在Amazon S3,Amazon DynamoDB或其他数据库中 Internet可用的存储服务.

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.

参考: AWS Lambda常见问题解答

因此,在您的情况下,我将首先将所有内容上载到S3,或者创建一个定期执行此操作的后台进程.这样,您可以通过Lambda函数访问它们,但不能直接从本地文件系统访问它们.

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.

这篇关于使用Aws Lambda将映像上传到AWS S3存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆