I have an app that needs to download some images from S3. I tried to setup a new CloudFront distribution, pointed the origin to my S3 bucket and wondering how will this change the way I access my images in my app. My app just request the images to S3 like that:
S3GetObjectRequest *getObjectRequest = [[S3GetObjectRequest alloc] initWithKey:path withBucket:PICTURE_BUCKET];
S3GetObjectResponse *getObjectResponse = [self.s3 getObject:getObjectRequest];
UIImage *img = [[UIImage alloc]initWithData:getObjectResponse.body];
Here, PICTURE_BUCKET is the name of my S3 bucket and path is the name of the image (64758_244.jpg).
How could I access this image through CloudFront?
I've found that
but I am new with Amazon Mobile Services development and I don't know how to do it.
Thanks.
If your question is simply how to find the URL to access Cloudfront images, this is one method.
From cloudfront, check the distribution settings (under the i icon) and note the domain name: I have one at: d3foqimq5fy14v.cloudfront.net and this is for my S3 bucket titled panchroma2013
In S3, open the properties pane for an image and copy the link URL I have one at: https://s3.amazonaws.com/panchroma2013/template/panchroma-website-design.png
While there, double check file permissions. You may have to add Grantee: Everyone, yes to Open/Download
The cloudfront url for this image is my cloudfront domain name + S3 url after the bucket name, ie:
http://d3foqimq5fy14v.cloudfront.net/template/panchroma-website-design.png
Hope this does the trick for you!