0
我使用ASIHTTPRequest将文件下载到ios设备 当我在创建请求后立即设置下载目标文件路径时,在我的代码是: 一个当使用ASIHTTPRequest设置requestDidReceiveResponseHeadersSelector中的下载目标文件路径时,下载数据时出错:方法
SIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:@"/Users/zxllf23/Desktop/download/tmp.zip"]];
[request setTemporaryFileDownloadPath:@"/Users/zxllf23/Desktop/download/tmp.zip.download"]];
但这不舒服,在服务器(BCS)不同的文件中有哪些我们可以从HTTP输入反应头的内容处置retrive不同的文件名,所以我要自动确定文件名,并且我在requestDidReceiveResponseHeadersSelector中写入了我的代码:方法
-(void) downloadReceiveRespone:(ASIHTTPRequest *)request
{
NSString *CoententDecription = [[request responseHeaders] objectForKey:@"Content-Disposition"];
NSString *filename = [self getFilenameFrom:CoententDecription];
[request setDownloadDestinationPath:[NSString stringWithFormat:@"/Users/zxllf23/Desktop/download/%@",filename]];
[request setTemporaryFileDownloadPath:[NSString stringWithFormat:@"/Users/zxllf23/Desktop/download/%@.download",filename]];
}
,我可以成功地下载文件,但不能打开正确的,我比较了原文件下载的文件数据,它们是不一样的
任何机构可以帮助我在这个问题上,我将非常感激。
谢谢JosephH,但以这种方式,那我该如何恢复以前的流产下载? – Roen
如果您需要恢复,我会首先提出建议:请求完成后移动文件。然后,您可以恢复正常,只有在文件完全下载成功后才将文件移动到最终位置。 – JosephH
谢谢,但我还是不太明白,你会更详细地解释,谢谢。 – Roen