简体   繁体   中英

how to put object by an external URL to amazon s3

With PHP

how to put object by an external URL to amazon s3?

So suppose I had a URL: http://example.com/file.avi I want to be able to move it into my bucket without downloading the file to my desktop and re-uploading the file. Is this possible?

S3 only supports copying objects from another S3 bucket, or uploading of local files. It is not possible to upload a resource located at an external URL. See here for more details: Put Object from remote resource in Amazon S3

You can do it using S3.php by tpyo https://github.com/tpyo/amazon-s3-php-class

Even it is not included in his ReadMe file, you can use the putObjectString() static function of it but you must convert first the url to string file by doing

$fileUrl = file_get_contents(" http://www.somesite.com/imagesample.png ");

S3::putObjectString($fileUrl, "yourBucket", "uploads/filenamehere.png");

More details: https://gist.github.com/neilmaledev/d255c42f1289a9ab9394121b7896d4d3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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