Skip to content

Commit

Permalink
2.9.4 pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobaidadada committed Feb 15, 2025
1 parent 202e647 commit 4afc7ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filecat",
"version": "2.9.3",
"version": "2.9.4",
"description": "filecat 文件管理器",
"author": "xiaobaidadada",
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions src/main/domain/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,16 @@ class FileService extends FileCompress {
readStream.pipe(ctx.res);
return;
}
if (!fileName.endsWith('.pdf')) {
ctx.res.attachment(fileName); // 设置文件名
}
if (stats.isFile()) {
let handle_type = "attachment";
if (fileName.endsWith('.pdf')) {
handle_type = "inline";
}
ctx.res.set({
"Content-Type": mime.lookup(fileName) || "application/octet-stream",
"Content-Length": fileSize,
// "Cache-Control": "public, max-age=3600",
"Content-Disposition": `attachment; filename="${encodedFileName}"; filename*=UTF-8''${encodedFileName}`
"Content-Disposition": `${handle_type}; filename="${encodedFileName}"; filename*=UTF-8''${encodedFileName}`
});
// 发送文件
const readStream = fs.createReadStream(sysPath);
Expand Down

0 comments on commit 4afc7ba

Please sign in to comment.