我正在從服務器下載pdf文件(250 MB)。當我保存到它的文檔目錄。它只有大小1 kb的損壞。從服務器下載大量數據
我使用的代碼如下:
if (!networkQueue) {
networkQueue = [[ASINetworkQueue alloc] init];
}
UIProgressView *myProgressIndicatorImg;;
[networkQueue setDelegate:self];
[networkQueue setDownloadProgressDelegate:myProgressIndicatorImg];
[networkQueue setShowAccurateProgress:YES];
[networkQueue bytesDownloadedSoFar];
[networkQueue setRequestDidFinishSelector:@selector(requestFinished:)];
[networkQueue setRequestDidReceiveResponseHeadersSelector :@selector(requestRecieved:)];
ASIHTTPRequest *request;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"example.com"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"E_governance"];
NSLog(@"E_governance media path is %@",dataPath);
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil]; //Create folder
NSString *savePath=[NSString stringWithFormat:@"%@/%@",dataPath,@"Filename1.mp3"];
[request setDownloadDestinationPath:savePath];
[request setUserInfo:[NSDictionary dictionaryWithObject:@"request1" forKey:@"name"]];
[networkQueue addOperation:request];
[networkQueue go];
任何人都可以讓我知道我做錯了什麼?
在此先感謝。
什麼是'ASINetworkQueue'?提供適當鏈接或標記問題(包括'objective-c')。 – trojanfoe 2015-03-03 10:54:32