waxical
waxical

Reputation: 3896

Upload to S3 via Cloudfront

So as we all know Cloudfront now supports uploading to S3 via the edge points.

However, I'm not really sure how to do this? I know it'll not be fully featured (i.e. not support authorize headers and part uploads) but I'm keen to do straight uploads.

I'm working in PHP, though it doesn't appear this is supported on the API yet as a method. Doing something rather simpler looks to require various authorisation milestones.

Has anyone found the best way to do this yet or just some suggestions for the best way as I'm trying CURL POST and other such things to no avail.

Upvotes: 3

Views: 2960

Answers (2)

imperalix
imperalix

Reputation: 3751

You should be able to do this now, I would give it another try. Be sure to use the S3 bucket's DNS name when signing your request, not your CloudFront distribution's.

Upvotes: 1

Jeremy Lindblom
Jeremy Lindblom

Reputation: 6527

You should probably read more about the browser-based POST uploads feature of Amazon S3 on the AWS docs. Doing an POST upload to Amazon S3 requires you to send a special JSON policy doc along with your POST request and upload. The S3 PostObject class in the AWS SDK for PHP is helpful for generating this policy, based on your provided options, as well as generating other form element values you need to include with your form/request.

Though I haven't tried it yet, you probably just need to swap out the S3 bucket endpoint for your CloudFront distribution endpoint to do the upload via the CloudFront edge location. Also, make sure your distribution is configured to accept POST requests. To get a more official answer to your question, I'd ask the Amazon CloudFront team on the CloudFront forum.

Upvotes: 4

Related Questions