简体   繁体   English

从 S3 向 EC2 发送文件 - AWS

[英]Send Files to EC2 from S3 - AWS

I have a mp4 file in my S3 bucket root.我的 S3 存储桶根目录中有一个 mp4 文件。 I just need to send that file to the "Downloads" tab in the EC2 Windows instance that I have and I need to do this by Lambda (Python).我只需将该文件发送到我拥有的 EC2 Windows 实例中的“下载”选项卡,我需要通过 Lambda (Python) 执行此操作。

Could you please tell me how to do this?你能告诉我怎么做吗? Thanks in Advance.提前致谢。

An Amazon EC2 instance is a computer just like any other computer -- it runs Windows or Linux just like normal. Amazon EC2 实例就像任何其他计算机一样是一台计算机——它像正常一样运行 Windows 或 Linux。

So, ask yourself "How would I copy a file to a Windows/Linux computer"?所以,问问自己“我如何将文件复制到 Windows/Linux 计算机”?

By default, computers don't get 'sent' files.默认情况下,计算机不会收到“发送”的文件。 You would need to interface with some software running on the Operating System, such as a web server, FTP server, or a shared drive across the network.您需要与操作系统上运行的某些软件进行交互,例如 web 服务器、FTP 服务器或网络上的共享驱动器。

If it is a Linux system, you could find a Python library that does SCP (eg Paramiko, see: How to scp in Python? ) and somehow call that from Lambda. If it is a Linux system, you could find a Python library that does SCP (eg Paramiko, see: How to scp in Python? ) and somehow call that from Lambda.

However, the better way is not to send the file to the EC2 instance.但是,更好的方法是不要将文件发送到 EC2 实例。 Instead, have the EC2 instance retrieve the object from S3.相反,让 EC2 实例从 S3 检索 object。 A common method is to have S3 send a message to an Amazon SQS queue that a program on the EC2 instance monitors, and then the program can download the object.一种常见的方法是让 S3 向 EC2 实例上的程序监控的 Amazon SQS 队列发送消息,然后该程序可以下载 object。 This is a much more 'secure' way to transfer the file, since the EC2 instance does not need to be open for inbound connections.这是一种更“安全”的文件传输方式,因为不需要为入站连接打开 EC2 实例。

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

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