Skip to content

Commit

Permalink
🐛Fixed downloading file or folder request
Browse files Browse the repository at this point in the history
  • Loading branch information
shepilov committed May 29, 2024
1 parent 88be9c9 commit ff2b3ab
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,15 @@ export class DocumentsController {
});

archive.pipe(response.raw);
return response;
} else if (archiveOrFile.file) {
const data = archiveOrFile.file;
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);
response.type(data.mime);
response.send(data.file);
return response.send(data.file);
}
} catch (error) {
logger.error({ error: `${error}` }, "failed to download file");
Expand Down

0 comments on commit ff2b3ab

Please sign in to comment.