Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASIHTTPRequestErrorDomain Code=8. Cannot move file from temp directory to docs

I download files with ASIHTTPReqeust. Everything downloads fine but it can't move file from temp directory to documents. When i implement

-(void) request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data

request fails with an error. But file is downloaded.

If i remove this implementation, everything is fine, and files are moving to docs. Here is Error text:

Error Domain=ASIHTTPRequestErrorDomain Code=8 "Failed to move file from '/var/folders/Qu/Qu0o0VcpEY4npJr2C1yPzE+++TI/-Tmp-/Skrillex feat. Nero - Wobbleland.mp3' to '/Users/Timur/Library/Application Support/iPhone Simulator/4.3/Applications/34389282-4013-4354-95D9-DF2847B4EE55/Documents/Audio/Skrillex feat. Nero - Wobbleland.mp3'" UserInfo=0x5949520 {NSUnderlyingError=0x59992a0 "The operation couldn’t be completed. (Cocoa error 4.)", NSLocalizedDescription=Failed to move file from '/var/folders/Qu/Qu0o0VcpEY4npJr2C1yPzE+++TI/-Tmp-/Skrillex feat. Nero - Wobbleland.mp3' to '/Users/Timur/Library/Application Support/iPhone Simulator/4.3/Applications/34389282-4013-4354-95D9-DF2847B4EE55/Documents/Audio/Skrillex feat. Nero - Wobbleland.mp3'}

Who had similar problem?

like image 454
Timur Mustafaev Avatar asked Dec 11 '25 16:12

Timur Mustafaev


1 Answers

Something that often catches people out is that you have to create the directory that you're downloading into yourself (ASIHTTPRequest won't create it automatically).

However given you say it's related to the implementing didReceiveData it's not that.

If you look at ASIHTTPRequest.m, you'll see it sets 'dataWillBeHandledExternally' if you implement 'didReceiveData' in the delegate - this will be preventing the data being written to disk. You can either write the data yourself, or you could change the ASIHTTPRequest.m code to add a flag to force it to handle the data internally too.

like image 138
JosephH Avatar answered Dec 14 '25 04:12

JosephH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!