ASIHTTPRequest 缓存+下载文件到本地
2012-08-20 17:12
465 查看
//路径
-(NSString*) pathToCachedResponseDataForStr:(NSString*)aStr{
NSURL *url = [NSURL URLWithString:aStr];
NSString *temCa = [[ASIDownloadCache sharedCache]pathToCachedResponseDataForURL:url];
#if DEBUG_LOG
NSLog(@"temCa: %@\n",temCa);
#endif
return temCa;
}
//下载文件
-(void)requestDataWithStr:(NSString*)aStr{
NSURL *url = [NSURL URLWithString:aStr];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];
[request setSecondsToCache:60*60*24*30];
[request setDownloadDestinationPath:
[[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:request]];
[request startAsynchronous];
}
-(NSString*) pathToCachedResponseDataForStr:(NSString*)aStr{
NSURL *url = [NSURL URLWithString:aStr];
NSString *temCa = [[ASIDownloadCache sharedCache]pathToCachedResponseDataForURL:url];
#if DEBUG_LOG
NSLog(@"temCa: %@\n",temCa);
#endif
return temCa;
}
//下载文件
-(void)requestDataWithStr:(NSString*)aStr{
NSURL *url = [NSURL URLWithString:aStr];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];
[request setSecondsToCache:60*60*24*30];
[request setDownloadDestinationPath:
[[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:request]];
[request startAsynchronous];
}
相关文章推荐
- ASIHTTPRequest的使用——文件下载(带缓存)
- ios (ASIHTTPRequest)获取下载资源文件大小
- 使用ASIHTTPRequest和ASIDownloadCache实现本地缓存
- <iOS>ASIHTTPRequest和ASIDownloadCache实现本地缓存
- ASIHTTPRequest系列(二):文件下载
- ios (ASIHTTPRequest)获取下载文件大小(size)
- iPhone开发笔记(16)使用ASIHTTPRequest和ASIDownloadCache实现本地缓存
- ASIHTTPRequest下载文件
- ASIHTTPRequest系列(2):文件下载
- ios (ASIHTTPRequest)获取下载文件大小(size)
- ASIHTTPRequest系列(二):文件下载
- ios中asihttprequest 下载缓存
- ASIHttpRequest 下载服务器上面的文件
- ASIHTTPRequest系列(二):文件下载
- 使用ASIHTTPRequest和ASIDownloadCache实现本地缓存
- ASIHTTPRequest系列(二):文件下载
- ASIHttpRequest下载服务端的mp3...文件
- ASIHTTPRequest和ASIDownloadCache实现本地缓存
- ASIHTTPRequest系列(二):文件下载
- ASIHTTPRequest系列(二):文件下载