From 6c7890b4fd25de9e809c4b3a5d3ae5b13ca36cf1 Mon Sep 17 00:00:00 2001 From: Jeremy Cloarec Date: Tue, 1 Oct 2024 09:58:29 +0200 Subject: [PATCH] [backend] disable file upload in draft --- .../opencti-graphql/src/database/file-storage-helper.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opencti-platform/opencti-graphql/src/database/file-storage-helper.ts b/opencti-platform/opencti-graphql/src/database/file-storage-helper.ts index 72942f4f36dc..6eb307a6fd76 100644 --- a/opencti-platform/opencti-graphql/src/database/file-storage-helper.ts +++ b/opencti-platform/opencti-graphql/src/database/file-storage-helper.ts @@ -8,6 +8,7 @@ import { logApp } from '../config/conf'; import { allFilesForPaths, EXPORT_STORAGE_PATH, IMPORT_STORAGE_PATH, SUPPORT_STORAGE_PATH } from '../modules/internal/document/document-domain'; import { deleteWorkForSource } from '../domain/work'; import { ENTITY_TYPE_SUPPORT_PACKAGE } from '../modules/support/support-types'; +import { inDraftContext } from '../utils/draftContext'; interface FileUploadOpts { entity?:BasicStoreBase | unknown, // entity on which the file is uploaded @@ -53,6 +54,7 @@ interface S3File { * @param opts */ export const uploadToStorage = (context: AuthContext, user: AuthUser, filePath: string, fileUpload: FileUploadData, opts: FileUploadOpts) => { + if (inDraftContext(context, user)) throw new Error('Cannot upload file in draft context'); return upload(context, user, filePath, fileUpload, opts); };