Stream Poco Zip Compression to Poco HTTPServerResponse -


i directly compress directory poco::httpserverresponse stream. however, downloading zip file produced following code leads corrupt archive. know below compression approach work locally created zip files have done much. missing or not possible? (poco v1.6.1)

std::string directory = "/tmp/data"; response.setstatusandreason(httpresponse::httpstatus::http_ok); response.setkeepalive(true); response.setcontenttype("application/zip"); response.set("content-disposition","attachment; filename=\"data.zip\""); poco::zip::compress compress(response.send(),false); compress.addrecursive(directory,     poco::zip::zipcommon::compressionmethod::cm_store,     poco::zip::zipcommon::compressionlevel::cl_maximum,     false, "data"); compress.close(); 

i use same technique successfully, slight difference: compression method , compression level (cm , cl).

compress.addfile( cachefile, poco::datetime(), currentfile.getname(), poco::zip::zipcommon::cm_deflate, poco::zip::zipcommon::cl_superfast ); 

a zip file corresponds deflate algorithm, when unzipping, explorer/archive manager doesn't work out. either that, or it's pointless use maximum level on store method (store non compressing definition).

edit: tried it, actually, it's because cm_store internally uses headers (probably kind of tar). once files have been added zip stream , close it, poco tries order header, , resets position of output stream start write them. since cannont done on http output stream (your bytes sent!), fails.

switching cm_deflate should fix problem.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -