If you do not have the luxury of simplicity using ASI and / or are stuck with the AWSiOS SDK, this is not so much:
/* borrowed from Maurício Linhares answer */ NSString *secretAccessKey = @"my-secret-access-key"; NSString *accessKey = @"my-access-key"; NSString *bucket = @"my-bucket"; NSString *path = @"path/to/the/object"; /********************************************/ AmazonCredentials *credentials = [[AmazonCredentials alloc] initWithAccessKey: accessKey withSecretKey: secretAccessKey]; AmazonS3Client *connection = [[AmazonS3Client alloc] initWithCredentials: credentials]; S3GetObjectRequest *downloadRequest = [[[S3GetObjectRequest alloc] initWithKey:path withBucket: bucket] autorelease]; [downloadRequest setDelegate: self]; /* only needed for delegate (see below) */ S3GetObjectResponse *downloadResponse = [self.awsConnection getObject: downloadRequest];
Then you can see downloadResponse.body and downloadResponse.httpStatusCode , preferably in the delegate:
-(void)request: (S3Request *)request didCompleteWithResponse: (S3Response *) response { NSLog(@"Download finished (%d)",response.httpStatusCode); }
source share