### What? Fixes client uploads when storage collection config has the `prefix` property configured. Previously, it failed with "Object key was not found". ### Why? This is expected to work. ### How? The client upload handler now receives to its props `prefix`. Then it threads it to the server-side `staticHandler` through `clientUploadContext` and then to `getFilePrefix`, which checks for `clientUploadContext.prefix` and returns if there is. Previously, `staticHandler` tried to load the file without including prefix consideration. This changes only these adapters: * S3 * Azure * GCS With the Vercel Blob adapter, `prefix` works correctly.
Google Cloud Storage for Payload
This package provides a simple way to use Google Cloud Storage with Payload.
NOTE: This package removes the need to use @payloadcms/plugin-cloud-storage as was needed in Payload 2.x.
Installation
pnpm add @payloadcms/storage-gcs
Usage
- Configure the
collectionsobject to specify which collections should use the Google Cloud Storage adapter. The slug must match one of your existing collection slugs. - When enabled, this package will automatically set
disableLocalStoragetotruefor each collection. - When deploying to Vercel, server uploads are limited with 4.5MB. Set
clientUploadstotrueto do uploads directly on the client. You must allow CORS PUT method for the bucket to your website.
import { gcsStorage } from '@payloadcms/storage-gcs'
import { Media } from './collections/Media'
import { MediaWithPrefix } from './collections/MediaWithPrefix'
export default buildConfig({
collections: [Media, MediaWithPrefix],
plugins: [
gcsStorage({
collections: {
media: true,
'media-with-prefix': {
prefix,
},
},
bucket: process.env.GCS_BUCKET,
options: {
apiEndpoint: process.env.GCS_ENDPOINT,
projectId: process.env.GCS_PROJECT_ID,
},
}),
],
})
Configuration Options
| Option | Description | Default |
|---|---|---|
enabled |
Whether or not to enable the plugin | true |
collections |
Collections to apply the storage to | |
bucket |
The name of the bucket to use | |
options |
Google Cloud Storage client configuration. See Docs | |
acl |
Access control list for files that are uploaded | Private |