mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
基于时间戳的文件下载secret
This commit is contained in:
1 parent
a6829863f2
commit
5e51bd2fe0
7 files changed
+118
-25
No files matched your search
@@ -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,
|
||||
};
|
||||
Reference in new issue
Block a user