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

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

问题描述

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



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

  ASIHTTPRequest *请求; 
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,视频文件等?任何限制,我,e,文件大小,超时?

似乎只需要设置远程文件路径,< a href =http://allseeing-i.com/ASIHTTPRequest/tests/images/small-image.jpg =nofollow noreferrer> http://allseeing-i.com/ASIHTTPRequest/tests/images/small -image.jpg ,那么可以使用HTTP协议远程下载所有内容。


  1. 简历功能如何?

它通过YES / NO提供RESUME的设置,是否足够用于正常恢复功能?例如,如果文件很大,请暂停,然后希望从上次恢复。



感谢任何投入或意见,我需要调查这一点,然后采用这个进入我的项目感谢您提前!

解决方案

您在同一时间在asi http请求组中发布了此内容,并得到了答案: / p>

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



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


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



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



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



和:



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


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

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];

My questions are:

  1. It can download any formats files, such as MP3, video file etc ? Any limitations, i,e, file size, time out ?

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. How about the resume function ?

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 !

解决方案

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

http://groups.google.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!)

Answers were (from BenC, the ASIHTTPRequest author):

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.

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.

and:

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天全站免登陆