feat: 瀏覽器下載文件時, 支持設定爲原始文件名

* 基於 Content-Disposition
This commit is contained in:
CrescentLeaf
2025-10-02 18:42:29 +08:00
parent 020fd63c97
commit e429bbbcdb

View File

@@ -45,6 +45,8 @@ app.get('/uploaded_files/:hash', (req, res) => {
}
}
const fileName = encodeURIComponent(file!.getName()?.replaceAll('"', ''))
res.setHeader('Content-Disposition', `inline; filename="${fileName}"`)
res.setHeader('Content-Type', file!.getMime())
res.sendFile(path.resolve(file!.getFilePath()))
})