开发者

Download files with one http request and no zipping

开发者 https://www.devze.com 2023-02-22 12:12 出处:网络
I need to download many photos and videos开发者_如何学编程 from the server. I am using cocoaasyncsocket library, and I could accomplish this by zipping all the contents and download the zipped file wi

I need to download many photos and videos开发者_如何学编程 from the server. I am using cocoaasyncsocket library, and I could accomplish this by zipping all the contents and download the zipped file with one button click.

But the problem is zipping the files take a lot of time. So, is there any way where I could download all the files without zipping them.


Sana, I was wrong, zip can be used in a stream:

zip -0 -r - .

will start recursively storing files from the current directory and send output to standard output. You can capture the standard output (see popen(3)) and begin sending it to clients immediately.


I had a similar problem when the creation of the zip archive took a long time but I needed to download more than one file.

The thing that saved me was http://pablotron.org/?cid=1568 Zip Stream is a class that creates the zip archive on the fly and while is being downloaded.

Most of the on the fly classes create the archive ( while you wait for the download to start ) and only after it is completely created, they start sending the archive to you. This class starts sending the archive as it is created, like this you will save the time that you wanted.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号