我正在开发一个从 amazon 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);
}
我设法让这个委托方法用于上传图像,但似乎无法让它用于下载。我需要做些什么来跟踪下载进度?
谢谢