关于使用 ASIHttpRequest 下载文件 [英] About download file using ASIHttpRequest

查看:31
本文介绍了关于使用 ASIHttpRequest 下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用 ASIHttpRequest 从后端服务器下载文件.在操作之前,请在此处发布问题以了解有关此功能的更多信息.

I plan to use ASIHttpRequest for downloading files from back-end server. Before actions, post questions here to know more about this feature.

作为示例源代码:(演示下载远程 JPG 文件)

As sample source codes given : ( demonstrate downloading remote JPG file )

    ASIHTTPRequest *request;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/small-image.jpg"]];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"1.png"]];
[request setDownloadProgressDelegate:imageProgressIndicator1];
[networkQueue addOperation:request];

我的问题是:

  1. 它可以下载任何格式的文件,例如 MP3、视频文件等?任何限制,即文件大小、超时?

好像只需要设置远程文件路径,"http://allseeing-i.com/ASIHTTPRequest/tests/images/small-image.jpg",那么它就可以通过HTTP协议远程下载所有内容.

Seem like that just need set up the remote file path, "http://allseeing-i.com/ASIHTTPRequest/tests/images/small-image.jpg", then it can download everything remotely with HTTP protocol.

  1. 简历功能怎么样?

它通过YES/NO提供了RESUME"的设置,这对于正常的恢复功能是否足够?比如文件很大,暂停一下,然后希望从上次恢复.

It provides setting for "RESUME" via YES/NO, is that enough for normal resume feature ? For example, if the file is big, pause it , then hope to resume it from last time.

感谢您的任何意见或意见,在将其纳入我的项目之前,我需要对此进行调查.提前致谢!

Thanks for any inputs or comments, I need investigate this before adopting this into my project. Thanks in advance !

推荐答案

您同时在 asi http 请求组中发布了此内容,并在那里得到了答复:

You posted this on the asi http request group at the same time, and got an answer there:

http://groups.google.com/.com/group/asihttprequest/browse_thread/thread/34eced6759cb7327/47aef091a77331fd?lnk=raot#47aef091a77331fd

(如果你要同时在多个地方发布你的问题,至少记录下你已经得到答案的事实是礼貌的!)

(If you're going to post your question in multiple places at the same time, it'd at least be polite to record the fact that you've already got an answer!)

答案是(来自 BenC,ASIHTTPRequest 的作者):

Answers were (from BenC, the ASIHTTPRequest author):

1:是的,您可以下载任何大小的任何文件.我认为唯一的理论限制是设备上的可用空间量.

1: Yes, you can download any file, of any size. I think the only theoretical limit is the amount of free space you have on the device.

默认情况下,如果 10 秒内没有收到任何数据,请求将超时.您可以通过设置请求的 timeoutSeconds 属性来增加超时时间,或者使用 [ASIHTTPRequest setDefaultTimeoutSeconds:x] 更改默认值.请注意,这并不意味着下载必须在 10 秒内完成,只是它不能卡住超过 10 秒.

By default, requests will time out if they have not received any data for 10 seconds. You can increase the timeout period by setting the timeoutSeconds property of the request, or change the default with [ASIHTTPRequest setDefaultTimeoutSeconds:x]. Note that this doesn't mean a download must complete in under 10 seconds, only that it must not get stuck for more than 10 seconds.

和:

2:是的,恢复功能是处理较大下载量的好方法,尤其是在 WWAN 连接上,在这种情况下,失去连接的情况更为常见.关于恢复下载要记住的两件事是:- 您必须提前配置要恢复的请求 - 如果您可能想在未来某个时间恢复请求,则必须在开始下载之前将其设置为恢复(有关详细信息,请参阅文档)- 并非所有下载都可以恢复 - 服务器必须支持您正在下载的资源的恢复.如果内容是动态生成的,一般不支持续传.

2: Yes, the resume feature is a good way to handle larger downloads, especially on WWAN connections where losing connectivity is much more common. The two things to remember about resuming downloads are: - You must configure requests to be resumed in advance - if you might want to resume a request at some future point, you must set it up to be resumed before you start the download (see the documentation for details) - Not all downloads can be resumed - the server must support resuming for the resource you are downloading. Generally, resuming is not supported if the content is dynamically generated.

这篇关于关于使用 ASIHttpRequest 下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆