mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: disable file proxy
This commit is contained in:
1 parent
e94846f868
commit
3e7306e232
3 files changed
+1
-33
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.2.35",
|
"version": "3.2.36",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -95,25 +95,9 @@ export class FSDownloadHandler extends Handler {
|
|||||||
target,
|
target,
|
||||||
size: file?.size || 0,
|
size: file?.size || 0,
|
||||||
});
|
});
|
||||||
if (!file) {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
this.response.redirect = await storage.signDownloadLink(
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
target, noDisposition ? undefined : filename, false, 'user',
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
const type = lookup(filename).toString();
|
|
||||||
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => type.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'] || type;
|
|
||||||
if (file['Content-Encoding']) this.response.addHeader('Content-Encoding', file['Content-Encoding']);
|
|
||||||
if (!noDisposition) this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
|
||||||
} else {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -617,25 +617,9 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
|
|||||||
target,
|
target,
|
||||||
size: file?.size || 0,
|
size: file?.size || 0,
|
||||||
});
|
});
|
||||||
if (!file) {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
this.response.redirect = await storage.signDownloadLink(
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
target, noDisposition ? undefined : filename, false, 'user',
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
if (file['Content-Encoding']) this.response.addHeader('Content-Encoding', file['Content-Encoding']);
|
|
||||||
if (!noDisposition) this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
|
||||||
} else {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user