我有一个内部 Ipad 应用程序,它通过过滤器、菜单等打开存储在网络上其他地方的文件。图像的主要格式是 Tiff 或 PDF,所以我使用网络将它们转换为 PDF(如果是 TIFF) -服务。用户要求包含 DWG 文件,我在 Ipad 上下载了 DWG 查看器。我想使用 AFNetworking 将 DWG 文件从服务器下载到 Ipad,但它似乎不起作用。相同的代码适用于 PDF 文件:
urlString = [urlString stringByAppendingString:strFile];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:req];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *outputPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:strFile];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:outputPath append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully downloaded file to %@", outputPath);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation start];
谢谢,
晒