-->

我应该从移动设备或从我的服务器上传文件到Amazon S3?(Should I upload fil

2019-10-21 16:28发布

我有亚马逊S3作为我的文件存储服务器和EC2实例作为我的应用程序逻辑服务器。 现在,我的应用程序需要上传这需要必要的处理一些文件。 我能想到的两种方法可以做到这一点:

  1. 直接从移动设备上传文件并获取文件名和位置(URL),然后将网址发送给我的后端。 后端得到通过URL文件并完成其工作。

  2. 发送文件使用多形式的后端,后端接受文件做其工作,并最终将文件保存到Amazon S3。

这是标准的方式吗? 究竟是什么原因?

Answer 1:

Sending the object direct to Amazon S3 will be more scalable, less error-prone and cheaper (since you need less web server capacity to handle the uploads). Send the corresponding information to a Simple Queueing Service (SQS) queue that the back-end service can monitor and process. That way, if your back-end is ever offline, the jobs will simply queue-up and will get processed when the server is running again. A good use of loose coupling.

A third option would be to send the file directly from your mobile to Amazon S3, using Metadata fields to identify originating user, and then configure the S3 bucket to trigger some code in AWS Lambda that can process the file. This could do all the processing, or could simply trigger a process on your web server. Again, this reduces load on the web server and would not require sending a message to trigger the processing.



文章来源: Should I upload files to Amazon S3 from mobile devices or from my server?