Reputation: 6377
I'm using following code to save the downloaded file to iphone/ipod-touch's documents directory.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
[receivedData writeToFile:basePath atomically:YES];
The file downloaded can be of any type which can be opened using Neooffice. The file is getting downloaded as I'm able to see a success message in console which is in connectionDidFinishLoading method along with the number of bytes received, but not getting saved at the given path.
EDIT:
It seems to be getting saved but in the form of .sqlite file which when opened is found empty. Don't know how to address this issue.
Can anybody please help?
Thanx in advance.
Upvotes: 0
Views: 523
Reputation: 170859
File path must contain file name, not only the directory where file should be:
[receivedData writeToFile:[basePath stringByAppendingPathComponent:yourFileName] atomically:YES];
While downloading you can get the file name in suggestedFilename
property of NSURLResponse or specify any name you want.
Upvotes: 1