tags:

views:

490

answers:

2

How do you copy a group of files from server machine to local hard disk through a C++ web application in one request? 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.

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?

A: 

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)

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. (see this).

pitr
zlib won't stick multiple files together by itself afaik, you'll need to use tar or similar for this
Hasturkun
+1  A: 

Say you have a Java servlet / ISAPI extension that accepts requests of the form

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.

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.

Modicom