For download a file, i do like this:
GTMSessionFetcher *fetcher = [self.service.fetcherService fetcherWithURLString:url];
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error)
{
[data writeToFile:localFilePath atomically:YES];
}];
File successfully downloaded but i can't get the download progress if you do like this.
fetcher.downloadProgressBlock = ^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite)
{
NSLog(@"bytesWritten = %lld",bytesWritten);
NSLog(@"totalBytesWritten = %lld",totalBytesWritten);
NSLog(@"totalBytesExpectedToWrite = %lld",totalBytesExpectedToWrite);
};
What am I doing wrong?
I found working solution.
float totalBytesExpectedToWrite = [file.size floatValue]; //file - it's GTLDriveFile to download
[fetcher setReceivedProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten)
{
NSLog(@"Download progress - %.0f",(totalBytesWritten * 100)/totalBytesExpectedToWrite);
}];