🐛 Fix files downloaded as untitled (#495)

This commit is contained in:
Montassar Ghanmy
2024-04-26 10:21:47 +01:00
committed by GitHub
parent 81a848c498
commit 0487ceb7b3
@@ -263,7 +263,7 @@ export class DocumentsController {
}>,
): Promise<any> => {
const { id } = request.params;
const update = request.body;
const update: any = request.body;
if (!id) throw new CrudException("Missing id", 400);
@@ -384,7 +384,7 @@ export class DocumentsController {
archive.pipe(response.raw);
} else if (archiveOrFile.file) {
const data = archiveOrFile.file;
const filename = data.name.replace(/[^a-zA-Z0-9 -_.]/g, "");
const filename = encodeURIComponent(data.name.replace(/[^\p{L}0-9 _.-]/gu, ""));
response.header("Content-disposition", `attachment; filename="${filename}"`);
if (data.size) response.header("Content-Length", data.size);