如何从远程服务器将文件直接上传到 Amazon S3? [英] How to upload files directly to Amazon S3 from a remote server?

查看:36
本文介绍了如何从远程服务器将文件直接上传到 Amazon S3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从远程服务器上传文件到 S3?

Is it possible to upload a file to S3 from a remote server?

远程服务器基本上是一个基于 URL 的文件服务器.例如,使用 http://example.com/1.jpg,它提供图像.它不执行任何其他操作,也无法在此服务器上运行代码.

The remote server is basically a URL based file server. Example, using http://example.com/1.jpg, it serves the image. It doesn't do anything else and can't run code on this server.

可以让另一台服务器告诉 S3 从 http://example.com/1.jpg

It is possible to have another server telling S3 to upload a file from http://example.com/1.jpg

           upload from http://example.com/1.jpg 
server -------------------------------------------> S3 <-----> example.com

推荐答案

如果您不能在服务器上运行代码或执行请求,那么,不,您不能这样做.您必须将文件下载到您拥有的服务器或计算机上,然后从那里上传.

If you can't run code on the server or execute requests then, no, you can't do this. You will have to download the file to a server or computer that you own and upload from there.

您可以在 http://docs.amazonwebservices.com 上查看您可以在 amazon S3 上执行的操作/AmazonS3/latest/API/APIRest.html

检查 REST 和 SOAP API 的操作,您会发现无法为 Amazon S3 提供远程 URL 并让它为您获取对象.所有 PUT 请求都要求将对象的数据作为请求的一部分提供.这意味着发起 Web 请求的服务器或计算机需要拥有数据.

Checking the operations for both the REST and SOAP APIs you'll see there's no way to give Amazon S3 a remote URL and have it grab the object for you. All of the PUT requests require the object's data to be provided as part of the request. Meaning the server or computer that is initiating the web request needs to have the data.

我过去曾遇到过类似的问题,我想下载用户的 Facebook 缩略图并将其上传到 S3 以在我的网站上使用.我这样做的方法是将图像从 Facebook 下载到我服务器上的内存中,然后上传到 Amazon S3 - 整个过程不到 2 秒.上传到 S3 完成后,将存储桶/密钥写入数据库.

I have had a similar problem in the past where I wanted to download my users' Facebook Thumbnails and upload them to S3 for use on my site. The way I did it was to download the image from Facebook into Memory on my server, then upload to Amazon S3 - the full thing took under 2 seconds. After the upload to S3 was complete, write the bucket/key to a database.

不幸的是,没有其他方法可以做到这一点.

Unfortunately there's no other way to do it.

这篇关于如何从远程服务器将文件直接上传到 Amazon S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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