mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(rest) streamPack: add one-click folder download
This commit is contained in:
parent
6c8c128b38
commit
11d9e1fef2
2 changed files with 36 additions and 19 deletions
|
|
@ -135,25 +135,40 @@
|
|||
if (p.name[0] === '/')
|
||||
cmd = p.name.replace('/', '');
|
||||
|
||||
switch(cmd) {
|
||||
case '':
|
||||
p.data = json.stringify({
|
||||
info: 'Cloud Commander API v1'
|
||||
});
|
||||
if (/^pack/.test(cmd)) {
|
||||
cmd = cmd.replace(/^pack/, '');
|
||||
streamPack(cmd, p.response, callback);
|
||||
} else {
|
||||
switch(cmd) {
|
||||
case '':
|
||||
p.data = json.stringify({
|
||||
info: 'Cloud Commander API v1'
|
||||
});
|
||||
|
||||
callback(null, {name: 'api.json'}, p.data);
|
||||
break;
|
||||
|
||||
callback(null, {name: 'api.json'}, p.data);
|
||||
break;
|
||||
|
||||
default:
|
||||
json = {
|
||||
message: 'Error: command not found!'
|
||||
};
|
||||
|
||||
callback(json);
|
||||
break;
|
||||
default:
|
||||
json = {
|
||||
message: 'Error: command not found!'
|
||||
};
|
||||
|
||||
callback(json);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function streamPack(cmd, response, fn) {
|
||||
var filename = cmd.replace(/\.tar\.gz$/, ''),
|
||||
dir = path.dirname(filename),
|
||||
names = [
|
||||
path.basename(filename)
|
||||
];
|
||||
|
||||
operation('pack', dir, response, names, fn);
|
||||
}
|
||||
|
||||
function auth(code, callback) {
|
||||
var storage = binom('storage', Modules),
|
||||
gh = binom('GitHub', storage),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue