How to put an object at an external url in amazon s3

With php

how to put object by external url in amazon s3?

So, suppose I have a URL: http://example.com/file.avi I want to transfer it to my bucket without downloading the file to my desktop and re-downloading the file. Is it possible?

+6
source share
2 answers

S3 only supports copying objects from another S3 bucket or downloading local files. Unable to load resource located at external URL. See here for more details: Place an object from a remote resource in Amazon S3

+1
source

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

Even it is not included in its ReadMe file, you can use the static function putObjectString (), but you must first convert the url to a 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

-2
source

All Articles