Feat: download as application/octet-stream

This commit is contained in:
Bluemangoo 2023-07-13 17:24:11 +08:00 committed by GitHub
parent 4a597b59f2
commit d5dca59253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,8 @@ router.get("/download/:key/:fileName", async (ctx) => {
const fileAbsPath = fileManager.toAbsolutePath(fileRelativePath);
const fileDir = path.dirname(fileAbsPath);
const fileName = path.basename(fileAbsPath);
ctx.set("Content-Type","application/octet-stream");
ctx.set("Content-Disposition","attachment");
await send(ctx, fileName, { root: fileDir + "/" });
} catch (error) {
ctx.body = $t("http_router.downloadErr", { error: error.message });