Search code examples
javaamazon-s3amazon-cloudfront

How to put object to S3 via CloudFront


I'd like to upload image to S3 via CloudFront. If you see the document about CloudFront, you can find that cloud front offers put method for uploading to cloudFront There could be someone to ask me why i use the cloud front for uploading to S3 If you search out about that, you can find the solution

What i wanna ask is whether there is method in SDK for uploading to cloud front or not As you know , there is method "putObejct" for uploading directly to S3 but i can't find for uploading cloud front ...

please help me..


Solution

  • Data can be sent through Amazon CloudFront to the back-end "origin". This is used for using a POST on web forms, to send information back to web servers. It can also be used to POST data to Amazon S3.

    If you would rather use an SDK to upload data to Amazon S3, there is no benefit in sending it "via CloudFront". Instead, use the Amazon S3 APIs to upload the data directly to S3.

    So, bottom line:

    • If you're uploading from a web page that was initially served via CloudFront, send it through CloudFront to S3
    • If you're calling an API, call S3 directly