Created
August 6, 2015 01:29
-
-
Save AlexanderBollbach/33d64c35bd10dd793418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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