Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I copy an object with presigned URL?

I'm using a service that puts the data I need on S3 and gives me a list of presigned URLs to download (http://.s3.amazonaws.com/?AWSAccessKeyID=...&Signature=...&Expires=...).
I want to copy those files into my S3 bucket without having to download them and upload again.

I'm using the Ruby SDK (but willing to try something else if it works..) and couldn't write anything like this.

I was able to initialize the S3 object with my credentials (access_key and secret) that grants me access to my bucket, but how do I pass the "source-side" access_key_id, signature and expires parameters?

To make the problem a bit simpler - I can't even do a GET request to the object using the presigned parameters. (not with regular HTTP, I want to do it through the SDK API).

I found a lot of examples of how to create a presigned URL but nothing about how to authenticate using an already given parameters (I obviously don't have the secret_key of my data provider).

Thanks!

like image 923
Zach Moshe Avatar asked Oct 31 '22 20:10

Zach Moshe


1 Answers

You can't do this with a signed url, but as has been mentioned, if you fetch and upload within EC2 in an appropriate region for the buckets in question, there's essentially no additional cost.

Also worth noting, both buckets do not have to be in the same account, but the aws key that you use to make the request have to have permission to put the target object and get the source object. Permissions can be granted across accounts... though in many cases, that's unlikely to be granted.

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html

like image 68
Michael - sqlbot Avatar answered Nov 14 '22 02:11

Michael - sqlbot