mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-04-07 05:01:24 +00:00
Merge pull request #1063 from Y8C68/fix/attachment-content-type
This commit is contained in:
@@ -93,11 +93,12 @@ export class AttachmentsController {
|
|||||||
const data = await this.attachmentsApplication.get(documentId);
|
const data = await this.attachmentsApplication.get(documentId);
|
||||||
|
|
||||||
const byte = await data.Body.transformToByteArray();
|
const byte = await data.Body.transformToByteArray();
|
||||||
const extension = mime.extension(data.ContentType);
|
const contentType = data.ContentType || 'application/octet-stream';
|
||||||
|
const extension = mime.extension(contentType) || 'bin';
|
||||||
const buffer = Buffer.from(byte);
|
const buffer = Buffer.from(byte);
|
||||||
|
|
||||||
res.set('Content-Disposition', `filename="${documentId}.${extension}"`);
|
res.set('Content-Disposition', `filename="${documentId}.${extension}"`);
|
||||||
res.set('Content-Type', data.ContentType);
|
res.set('Content-Type', contentType);
|
||||||
res.send(buffer);
|
res.send(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user