Reputation: 2234
We are currently using ASIHTTPRequest in our iPad application, which is a PDF viewer.
Currently the app downloads large PDF's 50+MB from our web server perfectly fine on the iPad 2 using this code:
However when we profile the application, we can see that during the download the application overall memory keeps on increasing whilst the download occurs to the full size of the PDF, and it looks like the app is writing to memory then out to disk?
Checking the ASI Documentation what we have looks correct, has anyone seen this issue before?
Thanks Aaron
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:@"/Users/ben/Desktop/my_file.pdf"];
Upvotes: 0
Views: 964
Reputation: 1797
Use NSFileManager to set destination directory path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"my_file.pdf"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:filePath];
Upvotes: 1
Reputation: 16827
You might have have to set the temporary download path so that it writes it to disk while downloading the document. As is, it could be keeping the whole thing in memory and crashing when the memory footprint has become unacceptable to the system. The documentation isn't entirely clear on this.
When downloading data to a file using downloadDestinationPath, data will be saved in a temporary file while the request is in progress. This file’s path is stored in temporaryFileDownloadPath.
I can't seem to find out what happens if temporaryFileDownloadPath is nil.
Upvotes: 0