Search code examples
iosobjective-camazon-s3amazon-cloudfront

Download images through CloudFront (Amazon)


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

iOS AWS SDK and CloudFront - accessing images

but I am new with Amazon Mobile Services development and I don't know how to do it.

Thanks.


Solution

  • If your question is simply how to find the URL to access Cloudfront images, this is one method.

    Hope this does the trick for you!