我正在潜入node.js的Zlib.我能够使用提供的示例(http://nodejs.org/api/zlib.html#zlib_examples)压缩和解压缩文件,但我无法找到有关为文件夹执行相同操作的更多信息?
一种可能性(但我认为是修补)是使用node-zip
模块并逐个添加文件夹的所有文件.但是在解压缩时我会遇到问题(在这种情况下我会丢失文件夹).
知道如何使用Node.js压缩(然后解压缩)整个文件夹(尊重子焊工层次结构)?
谢谢.
我想每个响应向用户发送多个文件。例如,用户请求索引站点,而站点需要一些.png、css 等。
用户只得到一个包含所有他需要的包。这就是想法。
所以我的想法是它会以这样的方式实现:
res.writeHead(200, {'Content-Type': 'text/html'});
var content = fs.readFileSync(applicationPath + "index.html");
res.write(content);
content = fs.readFileSync(applicationPath + "images/logo.png");
res.write(content);
content = fs.readFileSync(applicationPath + "index.css");
res.write(content);
res.end();
Run Code Online (Sandbox Code Playgroud)
这有可能吗?或者有其他解决方案吗?
感谢您的帮助和解答!