Reputation: 89
I'm getting this error "Terminating app due to uncaught exception AmazonServiceException
, reason: '(null)'" when requesting to get object from S3 here is my code:
AmazonS3Client *s3 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID
withSecretKey:SECRET_KEY];
S3TransferManager *tm = [S3TransferManager new];
tm.s3 = s3;
S3GetObjectRequest *getObjectRequest = [[S3GetObjectRequest alloc] initWithKey:@"1234/history.json" withBucket:S3TRANSFERMANAGER_BUCKET];
[s3 getObject:getObjectRequest];
S3GetObjectResponse *getObjectResponse = [s3 getObject:getObjectRequest];
NSData *data = getObjectResponse.body;
NSError *error = nil;
NSArray *jsonArrayNewObject = [NSJSONSerialization JSONObjectWithData:json options:kNilOptions error:&error];
NSArray *jsonArrayHistoryObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSMutableArray *historyList = [jsonArrayHistoryObject mutableCopy];
[historyList addObjectsFromArray:jsonArrayNewObject];
NSDictionary *dictionary = [[NSDictionary alloc] init];
dictionary = [historyList mutableCopy];
NSData *jsonData = [NSJSONSerialization
dataWithJSONObject:dictionary
options:NSJSONWritingPrettyPrinted
error:&error];
[self upload:jsonData];
Upvotes: 0
Views: 110
Reputation: 14905
I would have a look as the iOS Sample Application part of AWS iOS SDK : https://github.com/awslabs/aws-sdk-ios-samples
It contains a S3 file transfer (upload and download) sample
Upvotes: 1