diff --git a/packages/storage-azure/src/index.ts b/packages/storage-azure/src/index.ts index 4334f8781..3069d60c2 100644 --- a/packages/storage-azure/src/index.ts +++ b/packages/storage-azure/src/index.ts @@ -66,9 +66,27 @@ export const azureStorage: AzureStoragePlugin = {} as Record, ) + // Set disableLocalStorage: true for collections specified in the plugin options + const config = { + ...incomingConfig, + collections: (incomingConfig.collections || []).map((collection) => { + if (!collectionsWithAdapter[collection.slug]) { + return collection + } + + return { + ...collection, + upload: { + ...(typeof collection.upload === 'object' ? collection.upload : {}), + disableLocalStorage: true, + }, + } + }), + } + return cloudStorage({ collections: collectionsWithAdapter, - })(incomingConfig) + })(config) } function azureStorageInternal({ diff --git a/packages/storage-gcs/src/index.ts b/packages/storage-gcs/src/index.ts index e7fe6f462..49ea96189 100644 --- a/packages/storage-gcs/src/index.ts +++ b/packages/storage-gcs/src/index.ts @@ -66,9 +66,27 @@ export const gcsStorage: GcsStoragePlugin = {} as Record, ) + // Set disableLocalStorage: true for collections specified in the plugin options + const config = { + ...incomingConfig, + collections: (incomingConfig.collections || []).map((collection) => { + if (!collectionsWithAdapter[collection.slug]) { + return collection + } + + return { + ...collection, + upload: { + ...(typeof collection.upload === 'object' ? collection.upload : {}), + disableLocalStorage: true, + }, + } + }), + } + return cloudStorage({ collections: collectionsWithAdapter, - })(incomingConfig) + })(config) } function gcsStorageInternal({ acl, bucket, options }: GcsStorageOptions): Adapter { diff --git a/packages/storage-s3/src/index.ts b/packages/storage-s3/src/index.ts index b26cfa6d7..754eedb3c 100644 --- a/packages/storage-s3/src/index.ts +++ b/packages/storage-s3/src/index.ts @@ -79,9 +79,27 @@ export const s3Storage: S3StoragePlugin = {} as Record, ) + // Set disableLocalStorage: true for collections specified in the plugin options + const config = { + ...incomingConfig, + collections: (incomingConfig.collections || []).map((collection) => { + if (!collectionsWithAdapter[collection.slug]) { + return collection + } + + return { + ...collection, + upload: { + ...(typeof collection.upload === 'object' ? collection.upload : {}), + disableLocalStorage: true, + }, + } + }), + } + return cloudStorage({ collections: collectionsWithAdapter, - })(incomingConfig) + })(config) } function s3StorageInternal({ acl, bucket, config = {} }: S3StorageOptions): Adapter { diff --git a/packages/storage-vercel-blob/src/index.ts b/packages/storage-vercel-blob/src/index.ts index cd98b515a..f8392be23 100644 --- a/packages/storage-vercel-blob/src/index.ts +++ b/packages/storage-vercel-blob/src/index.ts @@ -106,9 +106,27 @@ export const vercelBlobStorage: VercelBlobStoragePlugin = {} as Record, ) + // Set disableLocalStorage: true for collections specified in the plugin options + const config = { + ...incomingConfig, + collections: (incomingConfig.collections || []).map((collection) => { + if (!collectionsWithAdapter[collection.slug]) { + return collection + } + + return { + ...collection, + upload: { + ...(typeof collection.upload === 'object' ? collection.upload : {}), + disableLocalStorage: true, + }, + } + }), + } + return cloudStorage({ collections: collectionsWithAdapter, - })(incomingConfig) + })(config) } function vercelBlobStorageInternal(