core: feat: 直链下载additional_file

This commit is contained in:
undefined committed 2021-01-03 21:29:37 +08:00
1 parent ea19d7997e
commit 91e7804fbb
2 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.15.9",
"version": "2.15.10",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+11
View File
@@ -497,6 +497,16 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
}
}
export class ProblemFileDownloadHandler extends ProblemDetailHandler {
@param('filename')
async get(domainId: string, filename: string) {
this.response.redirect = await storage.signDownloadLink(
`problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`,
filename, false, 'user',
);
}
}
export class ProblemSolutionHandler extends ProblemDetailHandler {
@param('page', Types.PositiveInt, true)
async get(domainId: string, page = 1) {
@@ -689,6 +699,7 @@ export async function apply() {
Route('problem_statistics', '/p/:pid/statistics', ProblemStatisticsHandler);
Route('problem_edit', '/p/:pid/edit', ProblemEditHandler);
Route('problem_files', '/p/:pid/files', ProblemFilesHandler);
Route('problem_file_download', '/p/:pid/file/:filename', ProblemFileDownloadHandler);
Route('problem_solution', '/p/:pid/solution', ProblemSolutionHandler);
Route('problem_solution_raw', '/p/:pid/solution/:psid/raw', ProblemSolutionRawHandler);
Route('problem_solution_reply_raw', '/p/:pid/solution/:psid/:psrid/raw', ProblemSolutionRawHandler);