mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(rest) add zip
This commit is contained in:
parent
e7ba46a9ca
commit
57329e4472
1 changed files with 21 additions and 1 deletions
|
|
@ -18,6 +18,7 @@
|
|||
path = main.path,
|
||||
Util = main.util,
|
||||
CloudFunc = main.cloudfunc,
|
||||
zlib = main.zlib,
|
||||
dir = main.dir,
|
||||
OK = 200,
|
||||
Header = main.generateHeaders({
|
||||
|
|
@ -141,7 +142,26 @@
|
|||
else
|
||||
main.sendError(pParams, pError);
|
||||
});
|
||||
else {
|
||||
else if (lQuery === 'zip') {
|
||||
lReadStream = fs.createReadStream(p.name);
|
||||
lWriteStream = fs.createWriteStream(p.name + '.zip');
|
||||
|
||||
lError = function(pError) {
|
||||
main.sendError(pParams, pError);
|
||||
};
|
||||
|
||||
lWriteStream.on('error', lError);
|
||||
lReadStream.on('error', lError);
|
||||
|
||||
lWriteStream.on('open', function() {
|
||||
lReadStream.pipe(zlib.createGzip()).pipe(lWriteStream);
|
||||
//p.request.pipe(process.stdout);
|
||||
lReadStream.on('end', function() {
|
||||
var lName = path.basename(p.name) + '.zip';
|
||||
main.sendResponse(pParams, 'save: ok("' + lName +'")');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
lWriteStream = fs.createWriteStream(p.name);
|
||||
|
||||
lError = function(pError) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue