From 91e7804fbbb6cd6c57165dd9abc218c90683e973 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 3 Jan 2021 21:29:37 +0800 Subject: [PATCH] =?UTF-8?q?core:=20feat:=20=E7=9B=B4=E9=93=BE=E4=B8=8B?= =?UTF-8?q?=E8=BD=BDadditional=5Ffile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 1493ef213..7ed5ca7e2 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -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", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index b5b536414..e7be5069a 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -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);