Search code examples
iphoneiosobjective-cipadmknetworkkit

Total size of downloading file using MKNetworkKit


I'm downloading a file using MKNetworkKit with the following code in the MKNetworkEngine subclass:

- (MKNetworkOperation *)downloadFileFromURL:(NSString *)urlString toFile:(NSString *)filePathString
{
    MKNetworkOperation *op = [self operationWithURLString:urlString params:nil httpMethod:@"GET"];
    [op addDownloadStream:[NSOutputStream outputStreamToFileAtPath:filePathString append:YES]];
    [self enqueueOperation:op];
    return op;
}

Any hints on how to show total size of downloading file or downloading rate?


Solution

  • If your server sends the Content-Size header, you can get the file size from

    operation.readonlyResponse.expectedContentLength