Merge pull request #55 from Bluemangoo/940

Feat: download as application/octet-stream
This commit is contained in:
unitwk 2023-07-16 19:05:42 +08:00 committed by GitHub
commit 6af709bbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,7 @@ 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");
await send(ctx, fileName, { root: fileDir + "/" });
} catch (error) {
ctx.body = $t("http_router.downloadErr", { error: error.message });