基于时间戳的文件下载secret

This commit is contained in:
masnn committed 2020-05-25 12:46:27 +08:00
1 parent a6829863f2
commit 5e51bd2fe0
7 files changed
+118 -25

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const file = require('../model/file');
const { Route, Handler } = require('../service/server');
class FileDownloadHandler extends Handler {
async get({ id, secret, name }) {
this.response.attachment(name || id);
this.response.body = await file.get(id, secret);
}
}
async function apply() {
Route('/fs/:id/:secret', module.exports.FileDownloadHandler);
}
global.Hydro.handler.file = module.exports = {
FileDownloadHandler,
apply,
};