xiw
xiw

Reputation: 75

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?

Upvotes: 7

Views: 8102

Answers (2)

neilmaledev
neilmaledev

Reputation: 1

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

Upvotes: -5

humbads
humbads

Reputation: 3412

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

Upvotes: 6

Related Questions