Downloading file with ASIHTTPRequest - iPhone app

雨燕双飞 提交于 2019-12-13 00:27:00

问题


I am using the ASIHTTPRequest source code to download a file from a remote location. Surprisingly, the download happens but nothing happens after that. I have put in a log statement in the handleBytesAvailable method and can see the entire file worth of data is downloaded in parts and added to the fileDownloadOutputStream variable.

But once all the bytes have been downloaded, nothing happens. The delegate methods are not called (neither fail, nor success).

Can someone please tell me what is happening? Or what is the correct way to download a file from a remote server using ASIHTTPRequest?

Thanks.

Few more details

On putting more log statements, it appears that after all the bytes have been downloaded, the request class gets a timeout response. And after that the delegate methods are not called. Not sure why the timeout should happen because I can see from the logs that all the bytes of the file have been downloaded already. Does this help?


回答1:


You can set the download location on the request:

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:@"/Users/ben/Desktop/my_file.txt"]];



回答2:


Have you set a delegate on the ASIHTTPRequest object?



来源:https://stackoverflow.com/questions/2729990/downloading-file-with-asihttprequest-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!