mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 19:32:37 +10:00
file content-disposition
This commit is contained in:
@ -5,10 +5,10 @@ export enum AttachmentType {
|
|||||||
File = 'file',
|
File = 'file',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validImageExtensions = ['.jpg', '.png', '.jpeg', 'gif'];
|
export const validImageExtensions = ['.jpg', '.png', '.jpeg'];
|
||||||
export const MAX_AVATAR_SIZE = '5MB';
|
export const MAX_AVATAR_SIZE = '5MB';
|
||||||
|
|
||||||
export const InlineFileExtensions = [
|
export const inlineFileExtensions = [
|
||||||
'.jpg',
|
'.jpg',
|
||||||
'.png',
|
'.png',
|
||||||
'.jpeg',
|
'.jpeg',
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import {
|
|||||||
import { getMimeType } from '../../common/helpers';
|
import { getMimeType } from '../../common/helpers';
|
||||||
import {
|
import {
|
||||||
AttachmentType,
|
AttachmentType,
|
||||||
|
inlineFileExtensions,
|
||||||
MAX_AVATAR_SIZE,
|
MAX_AVATAR_SIZE,
|
||||||
MAX_FILE_SIZE,
|
MAX_FILE_SIZE,
|
||||||
} from './attachment.constants';
|
} from './attachment.constants';
|
||||||
@ -177,6 +178,14 @@ export class AttachmentController {
|
|||||||
'Content-Type': attachment.mimeType,
|
'Content-Type': attachment.mimeType,
|
||||||
'Cache-Control': 'public, max-age=3600',
|
'Cache-Control': 'public, max-age=3600',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!inlineFileExtensions.includes(attachment.fileExt)) {
|
||||||
|
res.header(
|
||||||
|
'Content-Disposition',
|
||||||
|
`attachment; filename="${attachment.fileName}"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return res.send(fileStream);
|
return res.send(fileStream);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(err);
|
this.logger.error(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user