Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import data from URL to Amazon S3

I have a file with a pre-signed URL. I would like to upload that file directly to my S3 bucket without donwloading it first (I know how to do it with the intermediate step but I want to prevent it).

Any suggestion? Thanks in advance

like image 763
desmo Avatar asked Feb 13 '14 14:02

desmo


People also ask

How do I upload data to AWS S3?

In the Amazon S3 console, choose the bucket where you want to upload an object, choose Upload, and then choose Add Files. In the file selection dialog box, find the file that you want to upload, choose it, choose Open, and then choose Start Upload. You can watch the progress of the upload in the Transfer pane.

How do I get my S3 upload URL?

You can get the resource URL either by calling getResourceUrl or getUrl . AmazonS3Client s3Client = (AmazonS3Client)AmazonS3ClientBuilder. defaultClient(); s3Client. putObject(new PutObjectRequest("your-bucket", "some-path/some-key.

Can I move data directly to S3 glacier?

Lifecycle rules. Currently, there is no way of uploading objects directly to S3 Glacier using a Snowball Edge. Thus, you first have to upload your objects into S3 Standard, and then use S3 lifecycle policies to transition the files to S3 Glacier.

How does Presigned URL work S3?

S3 pre-signed URLs are a form of an S3 URL that temporarily grants restricted access to a single S3 object to perform a single operation — either PUT or GET — for a predefined time limit. To break it down: It is secure — the URL is signed using an AWS access key.


1 Answers

There is not a method supported by S3 that will accomplish what you are trying to do.

S3 does not support a request type that says, essentially, "go to this url and whatever you fetch from there, save it into my bucket under the following key."

The only option here is to fetch what you want, and then upload it. If the objects are large, and you don't want to dedicate the necessary disk space, you could fetch it in parts from the origin and upload it in parts using multipart upload... or if you are trying to save bandwidth somewhere, even the very small t1.micro instance located in the same region as the S3 bucket will likely give you very acceptable performance for doing the fetch and upload operation.


The single exception to this is where you are copying an object from S3, to S3, and the object is under 5 GB in size. In this case, you send a PUT request to the target bucket, accompanied by:

x-amz-copy-source: /source_bucket/source_object_key

That's not quite a "URL" and I assume you do not mean copying from bucket to bucket where you own both buckets, or you would have asked this more directly... but this is the only thing S3 has that resembles the behavior you are lookng for at all.

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

You can't use the signed URL here... the credentials you use to send the PUT request have to have permission to both fetch and store.

like image 115
Michael - sqlbot Avatar answered Nov 15 '22 23:11

Michael - sqlbot