core: add file fallback

This commit is contained in:
undefined committed 2021-08-18 23:20:40 +08:00
1 parent 9037a9bfd3
commit d37f485e30
6 files changed
+27 -7

No files matched your search

+6 -1
View File
@@ -417,7 +417,12 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
}
const target = `problem/${domainId}/${this.pdoc.docId}/${type}/${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 fileType = lookup(filename).toString();
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => fileType.includes(i)).length;