mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: use etag when proxy files
This commit is contained in:
1 parent
ebe0a08d3e
commit
bff83350a0
5 files changed
+5
-5
No files matched your search
@@ -424,10 +424,10 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
const fileType = lookup(filename).toString();
|
||||
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => fileType.includes(i)).length;
|
||||
if (shouldProxy && file.size! < 32 * 1024 * 1024) {
|
||||
this.response.etag = file.etag;
|
||||
this.response.body = await storage.get(target);
|
||||
this.response.type = file['Content-Type'] || fileType;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
|
||||
Reference in new issue
Block a user