You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
471 B
JavaScript
19 lines
471 B
JavaScript
4 years ago
|
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,
|
||
|
};
|