1

AFNetworking 3.1.0 を使用して、AWS S3 からいくつかの pdf をダウンロードしています。唯一の問題は、ファイルが gzip されると、ダウンロード進行状況ブロックが呼び出されないことです。

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"https://s3.amazonaws.com/awdtest/fullzip.pdf"];
NSURLRequest *request1 = [NSURLRequest requestWithURL:URL];

NSURLSessionDownloadTask *downloadTask1 = [manager downloadTaskWithRequest:request1 progress:^(NSProgress * _Nonnull downloadProgress)
{
    NSLog(@"Progress: %f", downloadProgress.fractionCompleted);
} destination:^NSURL *(NSURL *targetPath, NSURLResponse *response)
{
    NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
    return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error)
{
    NSLog(@"File downloaded to: %@", filePath);
}];
[downloadTask1 resume];

応答ヘッダー:

HTTP/1.1 200 OK
x-amz-id-2: CW06YcgIycOHZQy8bCJrT3aNfhatM9pty1mOjgYHumjCxRmNAQ+jhJHRQwl7mDIaQeTHI0fyrnU=
x-amz-request-id: 105E010DECC91897
Date: Sat, 14 May 2016 09:26:38 GMT
Content-Encoding: gzip
Last-Modified: Sat, 14 May 2016 09:21:29 GMT
ETag: "88bbe0b318bf11dd56a31176d3384e78"
Accept-Ranges: bytes
Content-Type: application/pdf
Content-Length: 1243325
Server: AmazonS3

gzip されていないファイルを使用すると、進行状況ブロックが呼び出されます: https://s3.amazonaws.com/awdtest/full.pdf

応答ヘッダー:

HTTP/1.1 200 OK
x-amz-id-2: gFOVfhheaMdeJOBb+7H8oaXjLLeOqlQl616XnYx6C2Gj7PBVLKZ9kMIN2fJOrGBcSgQ/7nbQOc0=
x-amz-request-id: 26669D9B576E300A
Date: Sat, 14 May 2016 09:54:58 GMT
Last-Modified: Fri, 16 May 2014 05:42:35 GMT
ETag: "6f16d7e09023ce8b50fd67abba7825c4"
Accept-Ranges: bytes
Content-Type: application/pdf
Content-Length: 1411131
Server: AmazonS3

助けていただければ幸いです。

ありがとう

4

1 に答える 1