diff --git a/packages/storage-gcs/src/index.ts b/packages/storage-gcs/src/index.ts index 6c14c0e46a6..f419e139b68 100644 --- a/packages/storage-gcs/src/index.ts +++ b/packages/storage-gcs/src/index.ts @@ -106,6 +106,29 @@ export const gcsStorage: GcsStoragePlugin = }) if (isPluginDisabled) { + // If alwaysInsertFields is true, still call cloudStoragePlugin to insert fields + if (gcsStorageOptions.alwaysInsertFields) { + // Build collections with adapter: null since plugin is disabled + const collectionsWithoutAdapter: CloudStoragePluginOptions['collections'] = Object.entries( + gcsStorageOptions.collections, + ).reduce( + (acc, [slug, collOptions]) => ({ + ...acc, + [slug]: { + ...(collOptions === true ? {} : collOptions), + adapter: null, + }, + }), + {} as Record, + ) + + return cloudStoragePlugin({ + alwaysInsertFields: true, + collections: collectionsWithoutAdapter, + enabled: false, + })(incomingConfig) + } + return incomingConfig }