如何下载多个文件与一个HTTP请求? [英] How to download multiple files with one HTTP request?

查看:850
本文介绍了如何下载多个文件与一个HTTP请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用案例:用户点击网页上的链接 - 轰!坐在他的文件夹中文件的负荷。结果
我试图收拾使用的multipart /混合消息的文件,但它似乎只适用于Firefox。

这是我的反应怎么是这样的:

  HTTP / 1.0 200 OK
连接:关闭
日期:星期三,2009年23点41分四十零秒GMT 6月24日
内容类型:多重/混合;边界= AMZ90RFX875LKMFasdf09DDFF3
客户日期:星期三,2009年二十三点41分40秒格林尼治标准​​时间6月24日
客户同行:127.0.0.1:3000
客户响应人数:1
MIME-版本:1.0
状态:200--AMZ90RFX875LKMFasdf09DDFF3
内容类型:image / JPEG
内容传输编码:二进制
内容处置:附件;文件名=001.JPG<<在这里不用二进制数据>> - AMZ90RFX875LKMFasdf09DDFF3
内容类型:image / JPEG
内容传输编码:二进制
内容处置:附件;文件名=002.JPG<<在这里不用二进制数据>> - AMZ90RFX875LKMFasdf09DDFF3
--AMZ90RFX875LKMFasdf09DDFF3--

感谢您搜索

P.S。不,压缩和解的文件是不是一种选择


解决方案

正在压缩的是,将对所有浏览器一致的结果是唯一的选择。如果这不是一种选择,因为你不知道的拉链可以动态生成,很好,他们可以。如果这不是一种选择,因为你对zip文件怀恨在心,以及..

的MIME /多部分为电子邮件消息和/或POST发送给HTTP服务器。这是从来没有打算接收并分析对HTTP事务的客户端。某些浏览器实现它,有些则没有。

作为另一种选择,你可以有一个JavaScript脚本打开下载各个文件窗口。或Java小程序(需要Java运行时机器上,如果它是一个企业应用程序,这不应该是一个问题[作为网管员可以在工作站上部署]),将下载的用户选择的一个目录中的文件。

Use case: user clicks the link on a webpage - boom! load of files sitting in his folder.
I tried to pack files using multipart/mixed message, but it seems to work only for Firefox

This is how my response looks like:

HTTP/1.0 200 OK
Connection: close
Date: Wed, 24 Jun 2009 23:41:40 GMT
Content-Type: multipart/mixed;boundary=AMZ90RFX875LKMFasdf09DDFF3
Client-Date: Wed, 24 Jun 2009 23:41:40 GMT
Client-Peer: 127.0.0.1:3000
Client-Response-Num: 1
MIME-Version: 1.0
Status: 200

--AMZ90RFX875LKMFasdf09DDFF3 
Content-type: image/jpeg 
Content-transfer-encoding: binary 
Content-disposition: attachment; filename="001.jpg" 

<< here goes binary data >>--AMZ90RFX875LKMFasdf09DDFF3 
Content-type: image/jpeg 
Content-transfer-encoding: binary 
Content-disposition: attachment; filename="002.jpg" 

<< here goes binary data >>--AMZ90RFX875LKMFasdf09DDFF3 
--AMZ90RFX875LKMFasdf09DDFF3--

Thank you

P.S. No, zipping files is not an option

解决方案

Zipping is the only option that will have consistent result on all browsers. If it's not an option because you don't know zips can be generated dynamically, well, they can. If it's not an option because you have a grudge against zip files, well..

MIME/multipart is for email messages and/or POST transmission to the HTTP server. It was never intended to be received and parsed on the client side of a HTTP transaction. Some browsers do implement it, some others don't.

As another alternative, you could have a JavaScript script opening windows downloading the individual files. Or a Java Applet (requires Java Runtimes on the machines, if it's an enterprise application, that shouldn't be a problem [as the NetAdmin can deploy it on the workstations]) that would download the files in a directory of the user's choice.

这篇关于如何下载多个文件与一个HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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