...
|
...
|
@@ -6,11 +6,13 @@ const rd = require('rd'); |
|
|
const shelljs = require('shelljs');
|
|
|
const decompress = require('decompress');
|
|
|
const decompressUnzip = require('decompress-unzip');
|
|
|
const ws = require('../../../lib/ws');
|
|
|
const qn = require('../../../lib/qiniu');
|
|
|
const Router = require('koa-router');
|
|
|
const router = new Router();
|
|
|
|
|
|
const QINIU_PREFIX = 'yoho';
|
|
|
const BROADCAST_PATH = '/upload';
|
|
|
|
|
|
const file = {
|
|
|
/**
|
...
|
...
|
@@ -19,7 +21,6 @@ const file = { |
|
|
page: async(ctx) => {
|
|
|
let result = await qn.listAsync('/yoho');
|
|
|
|
|
|
console.log('ALL-FILE-LIST:', result);
|
|
|
await ctx.render('/action/file_page', {fileList: result});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -46,18 +47,20 @@ const file = { |
|
|
await readable.pipe(writable);
|
|
|
|
|
|
readable.on('end', () => {
|
|
|
console.log('Zip file uploaded to Server!');
|
|
|
ws.broadcast(BROADCAST_PATH, {
|
|
|
state: 'Zip file uploaded to Server!'
|
|
|
});
|
|
|
});
|
|
|
|
|
|
console.log('Zip file savepath:', fileSavePath);
|
|
|
|
|
|
// 解压
|
|
|
await decompress(fileSavePath, fileDistPath, {
|
|
|
plugins: [
|
|
|
decompressUnzip()
|
|
|
]
|
|
|
}).then(() => {
|
|
|
console.log('Zip file decompressed');
|
|
|
ws.broadcast(BROADCAST_PATH, {
|
|
|
state: 'Zip file decompressed!'
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 上传到七牛处理
|
...
|
...
|
@@ -76,7 +79,9 @@ const file = { |
|
|
key: path.join(QINIU_PREFIX, fileList[i])
|
|
|
});
|
|
|
|
|
|
console.log(`${fileList[i]} Uploaded to Qiniu!`);
|
|
|
ws.broadcast(BROADCAST_PATH, {
|
|
|
state: `SUCCESS! ${fileList[i]} Uploaded to Qiniu!`
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|