简体   繁体   English

如何使用C ++在一个http请求中将多个文件从服务器复制到本地硬盘?

[英]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.

相关问题 C ++如何在不使用winapi的情况下移动文件并将它们从一个磁盘复制到另一个磁盘? - C++ how to move files and copy them from one disk to different without the usage of winapi? C++中的硬盘文件写入对象 - Writing objects to hard disk files in C++ 如何使用C / C ++获取硬盘的运行时间 - how to get the running time of a hard disk with C/C++ 如何在C++中使用WMI获取硬盘所有逻辑驱动器的空闲空间? - How to get free space of all logical drives of hard disk using WMI in C++? 如何设置C ++ Web应用程序服务器侦听来自tomcat / restlet服务器的http请求 - how to setup a C++ web application server listen to http request from a tomcat/restlet server 在Windows 7上用c ++格式化硬盘 - Formatting a hard disk in c++ on Windows 7 C ++中的远程过程调用(RPC):当端点进行硬编码时,多个客户端可以侦听一台服务器吗? - Remote Procedure Call (RPC) in C++: Can multiple Clients listen to one server when endpoint is hard coded? 获取辅助硬盘的空间-C ++ - Get the space of Secondary hard disk - c++ 在Linux上用C ++读取硬盘扇区 - Reading Hard Disk Sectors in C++ on Linux 显示使用C ++发送到我的服务器的HTTP请求 - Display HTTP Request sent to my server using c++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM