mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add file fallback
This commit is contained in:
1 parent
9037a9bfd3
commit
d37f485e30
6 files changed
+27
-7
No files matched your search
@@ -320,7 +320,12 @@ export class ContestProblemFileDownloadHandler extends ContestProblemHandler {
|
||||
if (typeof this.pdoc.docId === 'string') this.pdoc.docId = this.pdoc.docId.split(':')[1];
|
||||
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`;
|
||||
const file = await storage.getMeta(target);
|
||||
if (!file) throw new NotFoundError(filename);
|
||||
if (!file) {
|
||||
this.response.redirect = await storage.signDownloadLink(
|
||||
target, noDisposition ? undefined : filename, false, 'user',
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
const type = lookup(filename).toString();
|
||||
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => type.includes(i)).length;
|
||||
|
||||
Reference in new issue
Block a user