Merge pull request #6364 from nocodb/fix/attachment-part-2

fix: attachment for oss
This commit is contained in:
Fendy H
2025-07-31 14:55:49 +07:00
committed by GitHub

View File

@@ -1,4 +1,4 @@
import type { NcRequest } from 'nocodb-sdk';
import { NcApiVersion, type NcRequest } from 'nocodb-sdk';
import type { IBaseModelSqlV2 } from '~/db/IBaseModelSqlV2';
import { type AttachmentUrlUploadJobData, JobTypes } from '~/interface/Jobs';
import { EMIT_EVENT } from '~/constants';
@@ -22,6 +22,10 @@ export class AttachmentUrlUploadPreparator {
const postInsertOps: ((rowId: any) => Promise<string>)[] = [];
const preInsertOps: (() => Promise<string>)[] = [];
const postInsertAuditOps: ((rowId: any) => Promise<void>)[] = [];
// return early if not v3
if (baseModel.context.api_version !== NcApiVersion.V3) {
return { postInsertOps, preInsertOps, postInsertAuditOps };
}
for (const col of attachmentCols) {
let attachmentData: { id?: string; url: string }[];
try {
@@ -40,6 +44,8 @@ export class AttachmentUrlUploadPreparator {
} catch {
continue;
}
// only process when temp id exists
if (attachmentData.some((attr) => attr.id?.startsWith('temp_'))) {
postInsertOps.push(async (recordId) => {
Noco.eventEmitter.emit(EMIT_EVENT.HANDLE_ATTACHMENT_URL_UPLOAD, {
jobName: JobTypes.AttachmentUrlUpload,
@@ -59,6 +65,7 @@ export class AttachmentUrlUploadPreparator {
attachmentData.filter((dt) => !dt.id?.startsWith('temp_')),
);
}
}
return { postInsertOps, preInsertOps, postInsertAuditOps };
}
}