[英]How to copy multiple files from server to local hard disk in one http request using C++?
How do you copy a group of files from server machine to local hard disk through a C++ web application in one request? 如何在一个请求中通过C ++ Web应用程序将一组文件从服务器计算机复制到本地硬盘? This is kind of downloading bulk files to your local machine from a server.
这是从服务器将批量文件下载到本地计算机的一种。 I guess in Java you could do this through ZipInputStream and GZipInputStream.
我猜在Java中,您可以通过ZipInputStream和GZipInputStream做到这一点。
Is it possible to achieve this entirely through server side code? 是否有可能完全通过服务器端代码来实现? Or will it require a client running on the local machine to carry out the bulk copying of files?
还是需要在本地计算机上运行的客户端来执行文件的批量复制?
Say you have a Java servlet / ISAPI extension that accepts requests of the form 假设您有一个Java servlet / ISAPI扩展,可以接受以下形式的请求
http://server:port/fileserver?f=FILE1&f=FILE2&.....&f=FILEN http:// server:port / fileserver?f = FILE1&f = FILE2&.....&f = FILEN
On receipt of such a request, the server side code can, using zlib, pack all the files into a zip file and send the zip file as the HTTP response setting the Content-Type, Content-Length, Last-Modified,etc. 收到此类请求后,服务器端代码可以使用zlib将所有文件打包到一个zip文件中,并将该zip文件作为HTTP响应发送,设置Content-Type,Content-Length,Last-Modified等。
Further Note: If you are using ISAPI on IIS6 and above, you can also add this content into the IIS's kernel mode response cache. 进一步的注意:如果在IIS6及更高版本上使用ISAPI,则还可以将此内容添加到IIS的内核模式响应缓存中。
If the user if aware of this, and the files are not nessesary for website rendering, you can push them into an archive and have a link from your site (or do something like sourceforge, redirect to the archive and the browser simply downloads it. For archiving you can use zlib . Just send Content-type as gzip and push data (here from stdin) 如果用户意识到这一点,并且文件不需要用于网站渲染,则可以将其推送到存档中并从您的站点获得链接(或执行诸如sourceforge之类的操作,重定向到存档,浏览器只需下载它即可。要进行归档,您可以使用zlib ,只需将Content-type作为gzip发送并推送数据(此处来自stdin)
int ret;
/* avoid end-of-line conversions */
SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout);
ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
if (ret != Z_OK)
zerr(ret);
return ret;
If you are trying to have the whole page (HTML, CSS, JS, IMG) sent as one, all of those files can be inserted into HTML, even images. 如果您试图将整个页面(HTML,CSS,JS,IMG)作为一个页面发送,那么所有这些文件都可以插入HTML甚至图像中。 (see this ).
(参见此 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.