Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 and Cloudfront with Java API

I am currently using S3 with the Java API to get objects and their content. I've created a Cloudfront distribution using the AWS console and I set my S3 bucket with my objects as the Bucket-origin. But I didn't notice any improvement in the download performance, and I noticed in the console window the url refers to s3:

INFO: Sending Request: GET https://mybucket.s3.amazonaws.com /picture.jpg Headers: (Range: bytes=5001-1049479, Content-Type: application/x-www-form-urlencoded; charset=utf-8, )

whereas in the Getting Started guide for Cloudfront, the url should be:

http://(domain name)/picture.jpg

where (domain name) is specific to the Cloudfront distribution. So the Java API still is getting the file from S3 and not through cloudfront

Is there anyway using the Java API for S3 to download files via Cloudfront? If not, what's the best approach I should use to get objects via cloudfront in my java program? I am still kinda new to this stuff, any help greatly appreciated!

like image 812
Bobby Pardridge Avatar asked Nov 05 '22 19:11

Bobby Pardridge


1 Answers

JAVA API for S3 can not be used for interacting with Cloudfront.

If you want to download the content through cloud front distribution, you have to write your own HTTP code (which should be simple). You can also just use http://(cloud front domain name)/picture.jpg in browser and check the download speed first.

like image 144
vivek garg Avatar answered Nov 11 '22 09:11

vivek garg