0

I have an In-house Ipad App that opens files that are stored elsewhere on the network through filters, menus, etc. The Main Formats for the Images are Tiff or PDF, so I convert them to a PDF (if TIFF) using a web-service. Users are asking to include DWG files and I downloaded a DWG viewer on the Ipad. I would like to use AFNetworking to download the DWG file from the server to the Ipad but it doesn't seem to work. The same code works great for PDF files:

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];

Thanks,

Shai

shai4444
  • 43
  • 9

1 Answers1

0

From what I understand, AFNetworking can download any file. The problem here was on the Web Server settings, more specifically the Mime settings for .DWG files were missing.

shai4444
  • 43
  • 9