π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
limit upload size for base64
Fendy Heryanto654a3e526780
diff --git a/packages/nocodb/src/services/v3/data-attachment-v3.service.ts b/packages/nocodb/src/services/v3/data-attachment-v3.service.tsindex 37fb12ee98..65f2f7d65e 100644--- a/packages/nocodb/src/services/v3/data-attachment-v3.service.ts+++ b/packages/nocodb/src/services/v3/data-attachment-v3.service.ts@@ -31,6 +31,8 @@ const normalizeFilename = (filename: string) => {const thumbnailMimes = ['image/'];+const mb = 1024 * 1024;+@Injectable()export class DataAttachmentV3Service {constructor(@@ -155,6 +157,19 @@ export class DataAttachmentV3Service {const { context, modelId, columnId, recordId, scope, attachment, req } =param;+ const buffer = Buffer.from(attachment.file, 'base64');++ // Calculate file size from base64 value+ const fileSize = buffer.length;++ if (fileSize > NC_ATTACHMENT_FIELD_SIZE) {+ NcError.get(context).invalidRequestBody(+ `Attachment is larger than maximum allowed size at ${Math.floor(+ NC_ATTACHMENT_FIELD_SIZE / mb,+ )} mb`,+ );+ }+const baseModel = await getBaseModelSqlFromModelId({context: context,modelId: modelId,@@ -207,11 +222,6 @@ export class DataAttachmentV3Service {);const destPath = path.join('nc', scope ?? 'uploads', filePath);- const buffer = Buffer.from(attachment.file, 'base64');-- // Calculate file size from base64 value- const fileSize = buffer.length;-const resultAttachmentUrl = await storageAdapter.fileCreateByStream(slash(path.join(destPath, filename)),new PassThrough().end(buffer),