我正面臨着這個奇怪的問題。在點擊按鈕時,我正在從我的PHP服務器上下載媒體文件,如圖像,視頻和音頻。對於下載部分,我使用ASIHTTPRequest
。ASIHttpRequest - 移到活PHP服務器後不創建臨時文件
我使用此代碼爲重啓下載:
NSString *audio_url_f = [myDetailPeom poem_audio_url];
NSURL *url = [NSURL URLWithString:audio_url_f];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setShouldContinueWhenAppEntersBackground:YES];
[request setNumberOfTimesToRetryOnTimeout:3];
[request setDelegate:self];
//
NSString *path = [NSString stringWithFormat:@"%@/Documents/%@",NSHomeDirectory(),fileName];
path = [path stringByAppendingString:@".download"];
// This file has part of the download in it already
[request setTemporaryFileDownloadPath:path];
[request setAllowResumeForFileDownloads:YES];
[request setDownloadDestinationPath:filePath];
//
[request setUserInfo:[NSDictionary dictionaryWithObject:@"audio" forKey:@"type"]];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request startAsynchronous];
如果網絡發生故障時的下載停止和恢復正常。部分下載的文件在其文件名中附加.download
的位置正確創建。一旦網絡可用,它會正常恢復下載。
現在我將我的web應用程序移至活動的PHP服務器上(兩者都在同一臺服務器上)。但部分文件根本就沒有創建。
任何幫助表示讚賞。
與您的問題無關,但請考慮切換到其他框架,如「AFNetworking」。 'ASIHTTP'不再被作者維護/支持 – 2013-01-30 10:46:54