views:

172

answers:

1

i am using ASIHTTPRequest for downloading file from server but its giving error

Failed to move file from '/Users/admin/Library/Application Support/iPhone Simulator/3.1.3/Applications/8650FFE4-9C18-425C-9CEE-7392FD788E6D/Documents/temp/test.zip.download' to '/Users/admin/Library/Application Support/iPhone Simulator/3.1.3/Applications/8650FFE4-9C18-425C-9CEE-7392FD788E6D/Documents/test.zip'

can any body tell mw this error what wrong in my code......

NSURL *url = [NSURL URLWithString:@"http://wordpress.org/latest.zip"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self];

NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);

NSString *path = [NSString stringWithFormat:@"%@/test.zip", [dirArray objectAtIndex:0]];

//NSString *tempPath = [NSString stringWithFormat:@"%@test.zip", NSTemporaryDirectory()]    ;

NSString *tempPath =[NSString stringWithFormat:@"%@/temp/test.zip.download", [dirArray objectAtIndex:0]];

// The full file will be moved here if and when the request completes successfully
[request setDownloadDestinationPath:path];
[request setTemporaryFileDownloadPath:tempPath];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[[self queue] addOperation:request]; //queue is an NSOperationQueue
A: 

do you already have a temp.zip in that location ?

Andiih
i have temp zip in document folder but inside another folder TemporaryFileDownloadPath == @"%@/temp/test.zip.download"Download path == "%@/test.zip"can u answer for my problem now...?
jeeva
The ASIHTTPRequest documentation says that it will overwrite a file in the destination. BUt this is only mentioned in the case of the file not being a zip. It does not mention what happens if there is a file in the temporary folder or if the file is a zip. Try deleting the app from the simulator and re-running. If it works then, you may need to look at deleting the files before the download.
Andiih
Thanks andiih i checked storing zip TemporaryFileDownload file in tempDirectory than it works fine. if we give same directory then only it gives error.
jeeva