feat: Add attachment size for attachments (#15330)

## Description

- This PR address issue
https://github.com/twentyhq/core-team-issues/issues/1685
- Added attachment size limit upto 10mb for all google, microsoft and
SMTP provider

## Visual
<img width="348" height="117" alt="Screenshot 2025-10-24 at 5 35 34 PM"
src="https://github.com/user-attachments/assets/19d35b08-9a09-4ad4-aea5-e02cd6552d4d"
/>
This commit is contained in:
Harshit Singh
2025-10-24 19:14:51 +05:30
committed by GitHub
parent 5442e9fc37
commit b842da4f13
2 changed files with 13 additions and 0 deletions
@@ -1,5 +1,8 @@
import { MAX_ATTACHMENT_SIZE } from '@/advanced-text-editor/utils/MaxAttachmentSize';
import { formatFileSize } from '@/file/utils/formatFileSize';
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { useCreateFileMutation } from '~/generated-metadata/graphql';
import { logError } from '~/utils/logError';
@@ -21,6 +24,15 @@ export const useUploadWorkflowFile = () => {
file: File,
): Promise<WorkflowFile | null> => {
try {
if (file.size > MAX_ATTACHMENT_SIZE) {
const fileName = file.name;
const maxUploadSize = formatFileSize(MAX_ATTACHMENT_SIZE);
enqueueErrorSnackBar({
message: t`File "${fileName}" exceeds ${maxUploadSize}`,
});
return null;
}
const result = await createFile({
variables: { file },
});
@@ -0,0 +1 @@
export const MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024;