将文件上传到存储服务的最佳方式是什么? (Amazon S3 或 EdgeCast)

发布于 2024-10-07 22:13:44 字数 492 浏览 0 评论 0原文

我们有一个 Web 应用程序,需要使用 EdgeCast 或 Amazon S3 存储上传的图像。为此,我们需要首先将这些图像重新上传到 EdgeCast / S3。我能想到很多选项:

  1. 进行内联卷曲重新上传,这将使用所需的 EdgeCast / S3 API 上传图像。缺点是并发上传时服务器负载会很大。
  2. 队列重新上传。我知道这是可能的,但我不知道该怎么做。
  3. 不必费心重新上传并从客户端直接上传到 EdgeCast / S3。
  4. 挂载 EdgeCast / S3 的 FTP 到文件系统中,然后只需复制上传的文件,让 FTP 守护进程完成剩下的工作。

哪个是最好的解决方案,还有其他解决方案吗?我怀疑它是 1 或 2。

编辑:我的应用程序是 PHP

We have a web application which needs to store uploaded images with EdgeCast or Amazon S3. To do so we need to re-upload those images to EdgeCast / S3 first. There are a number of options I can think of:

  1. Do an inline curl re-upload, which will upload the image using the desired EdgeCast / S3 API. The disadvantage is that with concurrent uploads the server load will be massive.
  2. Queue re-uploads. I know it is possible but I have no idea how to do it.
  3. Don't bother with the re-uploads and upload directly to EdgeCast / S3 from the client end.
  4. Mount EdgeCast's / S3's FTP into the filesystem, and then just copy uploaded files, letting the FTP daemon do the rest.

Which is the best solution, and are there any other ones? I suspect it is either 1 or 2.

Edit: My application is in PHP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

私藏温柔 2024-10-14 22:13:44

不确定 EdgeCast,但我知道使用 Amazon S3 时,最好的方法是将文件直接 POST 到文件服务器。请参阅 http://doc.s3.amazonaws.com/proposals/post.html

通过这种方式,您将提供一个 HTML 表单,其中包含一些字段,如文件夹 ID、文件名、公钥、时间戳等,以确保它是安全的,并且只有您可以上传到服务器。一旦上传完成,服务器就会从重定向到的页面重定向浏览器,您可以检查查询字符串以了解上传是否成功,然后将 FileID 记录到数据库中。

非常适合减少服务器上的负载,并为用户提供更快的体验,但是如果上传成功但数据库插入失败,则可能会导致孤立文件。

Not sure about EdgeCast but I know with Amazon S3 the best way to do this was to POST the file directly to the file server. See http://doc.s3.amazonaws.com/proposals/post.html

Doing it this way you would provide a HTML FORM with some field like folder id, file name, public key, timestamp etc to ensure it was secure and only you could upload to the server. The server would redirect their browser once the upload was complete from that page they redirected to you could inspect the query string to find out if the upload was successful or not then record the FileID into your DB.

Works great for reducing load on your server and gives the user a faster experience, however it can lead to orphan files if the upload succeeds but the DB insert fails.

悸初 2024-10-14 22:13:44

EdgeCast 存储支持 Rsync/sFTP 配置以自动同步存储服务器中的内容。 EdgeCast 还支持“反向代理”或“客户来源”配置,自动将内容从另一个 Web 服务器提取到缓存中。您可以使用 S3 作为此客户源位置,或使用 EdgeCast 自己的云存储服务或 EdgeCast 网络外部的任何其他 Web 服务器。

EdgeCast storage supports Rsync/sFTP configuration to automatically sync content from a storage server. EdgeCast also supports "reverse-proxy" or "Customer Origin" configuration to pull content from another web-server into cache automatically. You can use S3 as this Customer-origin location or use EdgeCast's own Cloud Storage service or any other Web-server outside the EdgeCast network.

清风不识月 2024-10-14 22:13:44

我所做的是将文件上传到临时目录,然后运行一个 cron 脚本,将文件放到 AWS 上,以免导致最终用户的上传过程花费更长的时间。

What I do is upload the files to a temp directory then have a cron script run that PUT's the files onto AWS, so as not to cause the upload process to take any longer for the end-user.

疑心病 2024-10-14 22:13:44

AWS 提供了一个 PHP SDK 来执行此操作。它甚至支持分段上传,这对开发人员来说是个好消息。

应该注意的是,适用于 PHP 的 AWS 开发工具包还会执行重试逻辑,并且(如果您使用的是 Multipart,您应该这样做)可以恢复失败的上传。

AWS provides an SDK for PHP to do this. It even has support for multi-part uploads, which is great news for developers.

It should be noted that the AWS SDK for PHP will also do retry logic and (if you're using Multipart, which you should) can resume failed uploads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文