Skip to content

Instantly share code, notes, and snippets.

@AlexanderBollbach
Created August 6, 2015 01:29
Show Gist options
  • Save AlexanderBollbach/33d64c35bd10dd793418 to your computer and use it in GitHub Desktop.
Save AlexanderBollbach/33d64c35bd10dd793418 to your computer and use it in GitHub Desktop.
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
// Construct the NSURL for the download location.
NSString* downloadingFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"downloaded-myImage.jpg"];
NSURL *downloadingFileURL = [NSURL fileURLWithPath:downloadingFilePath];
// Construct the download request.
AWSS3TransferManagerDownloadRequest *downloadRequest = [AWSS3TransferManagerDownloadRequest new];
downloadRequest.bucket = @"alexanderbollbachbucket";
downloadRequest.key = @"earth.jpg";
downloadRequest.downloadingFileURL = downloadingFileURL;
// Download the file.
[[transferManager download:downloadRequest] continueWithExecutor:[AWSExecutor mainThreadExecutor]
withBlock:^id(AWSTask *task) {
if (task.error){
if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
switch (task.error.code) {
case AWSS3TransferManagerErrorCancelled:
case AWSS3TransferManagerErrorPaused:
break;
default:
NSLog(@"Error: %@", task.error);
break;
}
} else {
// Unknown error.
NSLog(@"Error: %@", task.error);
}
}
if (task.result) {
AWSS3TransferManagerDownloadOutput *downloadOutput = task.result;
self.imageView.image = [UIImage imageWithContentsOfFile:downloadingFilePath];
}
return nil;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment