Новые upload-методы
This commit is contained in:
@@ -76,6 +76,8 @@ class WebSocketController {
|
|||||||
await this.readerStorageDo(req, ws); break;
|
await this.readerStorageDo(req, ws); break;
|
||||||
case 'upload-file-buf':
|
case 'upload-file-buf':
|
||||||
await this.uploadFileBuf(req, ws); break;
|
await this.uploadFileBuf(req, ws); break;
|
||||||
|
case 'upload-file-touch':
|
||||||
|
await this.uploadFileTouch(req, ws); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Action not found: ${req.action}`);
|
throw new Error(`Action not found: ${req.action}`);
|
||||||
@@ -182,7 +184,12 @@ class WebSocketController {
|
|||||||
this.send({url: await this.readerWorker.saveFileBuf(req.buf)}, req, ws);
|
this.send({url: await this.readerWorker.saveFileBuf(req.buf)}, req, ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async uploadFileTouch(req, ws) {
|
||||||
|
if (!req.url)
|
||||||
|
throw new Error(`key 'url' is empty`);
|
||||||
|
|
||||||
|
this.send({url: await this.readerWorker.uploadFileTouch(req.url)}, req, ws);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WebSocketController;
|
module.exports = WebSocketController;
|
||||||
|
|||||||
@@ -232,6 +232,14 @@ class ReaderWorker {
|
|||||||
return `disk://${hash}`;
|
return `disk://${hash}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async uploadFileTouch(url) {
|
||||||
|
const outFilename = `${this.config.uploadDir}/${url.replace('disk://', '')}`;
|
||||||
|
|
||||||
|
await utils.touchFile(outFilename);
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
async restoreRemoteFile(filename) {
|
async restoreRemoteFile(filename) {
|
||||||
const basename = path.basename(filename);
|
const basename = path.basename(filename);
|
||||||
const targetName = `${this.config.tempPublicDir}/${basename}`;
|
const targetName = `${this.config.tempPublicDir}/${basename}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user