Reputation: 65815
I am trying to find a way to put an object that is somewhere in the internet to Amazon S3 without having to download it first and then upload it to S3. Is it fundamentally possible?
I am using Node.js SDK. Ideally I want to do something like this:
s3.client.putObject({
Bucket: 'my-own-bucket',
Key: 'myKey',
BodyFromRemoteRecource: 'https://www.google.com/images/srpr/logo4w.png'
}, function(err, data) {
if (err)
console.log(err)
else
console.log("Successfully uploaded data to myBucket/myKey");
});
Upvotes: 4
Views: 5777
Reputation: 9690
Something like this works for me with the PHP2 SDK:
$aws_transfer = $s3->PutObject( array(
'Bucket' => 'bucket',
'Key' => $unique_file_name,
'Body' => \Guzzle\Http\EntityBody::factory( file_get_contents('http://www.example.com/file.flv') ),
) );
Upvotes: 2
Reputation: 5649
You can do it if the source is somewhere on S3 already, but not for other resources. So no, you can't do what your example use case asks.
You can move data from a URL to S3 without fully downloading it one step before uploading, if that would help. Every byte would still have to go through some machine you have, but you could GET and then PUT it a chunk at a time.
The entire S3 API is documented here, and you can check every operation and see that there isn't anything that will do this.
Upvotes: 5