Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

transform attachment

Fendy Heryantoae60b715325f
diff --git a/packages/nocodb/src/services/v3/data-v3.service.ts b/packages/nocodb/src/services/v3/data-v3.service.ts
index aba4a2193d..05dff64fc9 100644
--- a/packages/nocodb/src/services/v3/data-v3.service.ts
+++ b/packages/nocodb/src/services/v3/data-v3.service.ts
@@ -2,6 +2,7 @@ import { NcApiVersion, RelationTypes, UITypes } from 'nocodb-sdk';
import { Injectable } from '@nestjs/common';
import { NcError } from 'src/helpers/catchError';
import { getCompositePkValue } from 'src/helpers/dbHelpers';
+import { extractProps } from 'src/helpers/extractProps';
import type {
DataDeleteParams,
DataInsertParams,
@@ -256,6 +257,32 @@ export class DataV3Service {
});
continue;
}
+ } else if (column?.uidt === UITypes.Attachment) {
+ if (value) {
+ let attachmentVal: any[] = value as any;
+ if (!Array.isArray(value) && typeof value === 'string') {
+ attachmentVal = JSON.parse(value);
+ } else if (!Array.isArray(attachmentVal)) {
+ // unknown format, let's not handle it yet
+ continue;
+ }
+
+ attachmentVal = attachmentVal.map((attr) =>
+ extractProps(attr, [
+ 'id',
+ 'url',
+ 'path',
+ 'title',
+ 'mimetype',
+ 'size',
+ 'icon',
+ 'width',
+ 'height',
+ ]),
+ );
+ transformedFields[key] = attachmentVal;
+ continue;
+ }
}
}