mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 15:46:00 +00:00
Merge pull request #6364 from nocodb/fix/attachment-part-2
fix: attachment for oss
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user