我应该从移动设备还是从服务器将文件上传到Amazon S3? [英] Should I upload files to Amazon S3 from mobile devices or from my server?

查看:81
本文介绍了我应该从移动设备还是从服务器将文件上传到Amazon S3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Amazon S3作为文件存储服务器,并将EC2实例作为应用程序逻辑服务器.现在,我的应用程序需要上传一些需要进行必要处理的文件.我可以想到两种方法:

I have Amazon S3 as my file storage server and EC2 instances as my application logic server. Now my app needs to upload some files which need necessary processing. I can think of two ways to do this:

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

  1. Upload the file directly from mobile devices and get the file name and location(url), then send the url to my backend. Backend get the file by URL and do its job.

使用多部分形式将文件发送到后端,后端接受文件执行其工作,最后将文件保存到Amazon S3.

Send the file to backend using a multipart form, backend accepts the file do its job and finally save the file to Amazon S3.

哪种是标准方式?是什么原因?

Which is the standard way? What are the reasons?

推荐答案

将对象直接发送到Amazon S3将具有更高的可伸缩性,更少的错误发生和更便宜的价格(因为您需要更少的Web服务器容量来处理上传).将相应的信息发送到后端服务可以监视和处理的简单队列服务(SQS)队列.这样,如果您的后端处于脱机状态,则作业将简单地排队,并在服务器再次运行时得到处理.善用松耦合.

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.

第三个选择是使用元数据字段标识原始用户,将文件直接从您的移动设备直接发送到Amazon S3,然后配置S3存储桶以触发

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.

这篇关于我应该从移动设备还是从服务器将文件上传到Amazon S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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