我正在從亞馬遜s3下載圖像的iOS應用程序。我試圖跟蹤圖片下載的進度。亞馬遜s3 ios下載進度條
我不能讓-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
委託方法觸發。
這是我至今設置委託方法的代碼。
-(void) viewDidLoad
{
self.s3 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY];
self.s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
NSString *key = [[NSString alloc] initWithFormat:@"path1/%@", uniqueID];
S3GetObjectRequest *downloadRequest = [[S3GetObjectRequest alloc] initWithKey:key withBucket: PICTURE_BUCKET];
[downloadRequest setDelegate:self];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Loading Picture...";
S3GetObjectResponse *downloadResponse = [s3 getObject:downloadRequest];
}
-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
NSLog(@"Bytes Written: %i", bytesWritten);
NSLog(@"Total Bytes Written: %i", totalBytesWritten);
NSLog(@"Total Bytes Expected to Write: %i", totalBytesExpectedToWrite);
}
我設法讓這個委託方法工作上傳圖像,但似乎無法讓它下載工作。爲了追蹤下載進度,我需要做什麼不同的事情?
感謝
希望這個鏈接將幫助你! http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html#track-progress – arunjos007