Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Storage Adapters

Payload offers additional storage adapters to handle file uploads. These adapters allow you to store files in different locations, such as Amazon S3, Vercel Blob Storage, Google Cloud Storage, and more.

Vercel Blob Storage

@payloadcms/storage-vercel-blob

Installation

1
pnpm add @payloadcms/storage-vercel-blob

Usage

  • Configure the collections object to specify which collections should use the Vercel Blob adapter. The slug must match one of your existing collection slugs.
  • Ensure you have BLOB_READ_WRITE_TOKEN set in your Vercel environment variables. This is usually set by Vercel automatically after adding blob storage to your project.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
1
import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'
2
import { Media } from './collections/Media'
3
import { MediaWithPrefix } from './collections/MediaWithPrefix'
4
5
export default buildConfig({
6
collections: [Media, MediaWithPrefix],
7
plugins: [
8
vercelBlobStorage({
9
enabled: true, // Optional, defaults to true
10
// Specify which collections should use Vercel Blob
11
collections: {
12
media: true,
13
'media-with-prefix': {
14
prefix: 'my-prefix',
15
},
16
},
17
// Token provided by Vercel once Blob storage is added to your Vercel project
18
token: process.env.BLOB_READ_WRITE_TOKEN,
19
}),
20
],
21
})

Configuration Options

OptionDescriptionDefault
enabledWhether or not to enable the plugintrue
collectionsCollections to apply the Vercel Blob adapter to
addRandomSuffixAdd a random suffix to the uploaded file name in Vercel Blob storagefalse
cacheControlMaxAgeCache-Control max-age in seconds365 * 24 * 60 * 60 (1 Year)
tokenVercel Blob storage read/write token''

S3 Storage

@payloadcms/storage-s3

Installation

1
pnpm add @payloadcms/storage-s3

Usage

  • Configure the collections object to specify which collections should use the S3 Storage adapter. The slug must match one of your existing collection slugs.
  • The config object can be any S3ClientConfig object (from @aws-sdk/client-s3). This is highly dependent on your AWS setup. Check the AWS documentation for more information.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
1
import { s3Storage } from '@payloadcms/storage-s3'
2
import { Media } from './collections/Media'
3
import { MediaWithPrefix } from './collections/MediaWithPrefix'
4
5
export default buildConfig({
6
collections: [Media, MediaWithPrefix],
7
plugins: [
8
s3Storage({
9
collections: {
10
media: true,
11
'media-with-prefix': {
12
prefix,
13
},
14
},
15
bucket: process.env.S3_BUCKET,
16
config: {
17
credentials: {
18
accessKeyId: process.env.S3_ACCESS_KEY_ID,
19
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
20
},
21
region: process.env.S3_REGION,
22
// ... Other S3 configuration
23
},
24
}),
25
],
26
})

Configuration Options

See the the AWS SDK Package and S3ClientConfig object for guidance on AWS S3 configuration.

Azure Blob Storage

@payloadcms/storage-azure

Installation

1
pnpm add @payloadcms/storage-azure

Usage

  • Configure the collections object to specify which collections should use the Azure Blob adapter. The slug must match one of your existing collection slugs.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
1
import { azureStorage } from '@payloadcms/storage-azure'
2
import { Media } from './collections/Media'
3
import { MediaWithPrefix } from './collections/MediaWithPrefix'
4
5
export default buildConfig({
6
collections: [Media, MediaWithPrefix],
7
plugins: [
8
azureStorage({
9
collections: {
10
media: true,
11
'media-with-prefix': {
12
prefix,
13
},
14
},
15
allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
16
baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
17
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
18
containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
19
}),
20
],
21
})

Configuration Options

OptionDescriptionDefault
enabledWhether or not to enable the plugintrue
collectionsCollections to apply the Azure Blob adapter to
allowContainerCreateWhether or not to allow the container to be created if it does not existfalse
baseURLBase URL for the Azure Blob storage account
connectionStringAzure Blob storage connection string
containerNameAzure Blob storage container name

Google Cloud Storage

@payloadcms/storage-gcs

Installation

1
pnpm add @payloadcms/storage-gcs

Usage

  • Configure the collections object 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 disableLocalStorage to true for each collection.
1
import { gcsStorage } from '@payloadcms/storage-gcs'
2
import { Media } from './collections/Media'
3
import { MediaWithPrefix } from './collections/MediaWithPrefix'
4
5
export default buildConfig({
6
collections: [Media, MediaWithPrefix],
7
plugins: [
8
gcsStorage({
9
collections: {
10
media: true,
11
'media-with-prefix': {
12
prefix,
13
},
14
},
15
bucket: process.env.GCS_BUCKET,
16
options: {
17
apiEndpoint: process.env.GCS_ENDPOINT,
18
projectId: process.env.GCS_PROJECT_ID,
19
},
20
}),
21
],
22
})

Configuration Options

OptionDescriptionDefault
enabledWhether or not to enable the plugintrue
collectionsCollections to apply the storage to
bucketThe name of the bucket to use
optionsGoogle Cloud Storage client configuration. See Docs
aclAccess control list for files that are uploadedPrivate

Uploadthing Storage

@payloadcms/storage-uploadthing

Installation

1
pnpm add @payloadcms/storage-uploadthing

Usage

  • Configure the collections object to specify which collections should use uploadthing. The slug must match one of your existing collection slugs and be an upload type.
  • Get a token from Uploadthing and set it as token in the options object.
  • acl is optional and defaults to public-read.
1
export default buildConfig({
2
collections: [Media],
3
plugins: [
4
uploadthingStorage({
5
collections: {
6
media: true,
7
},
8
options: {
9
token: process.env.UPLOADTHING_TOKEN,
10
acl: 'public-read',
11
},
12
}),
13
],
14
})

Configuration Options

OptionDescriptionDefault
tokenToken from Uploadthing. Required.
aclAccess control list for files that are uploadedpublic-read
logLevelLog level for Uploadthinginfo
fetchCustom fetch functionfetch
defaultKeyTypeDefault key type for file operationsfileKey

Custom Storage Adapters

If you need to create a custom storage adapter, you can use the @payloadcms/plugin-cloud-storage package. This package is used internally by the storage adapters mentioned above.

Installation

pnpm add @payloadcms/plugin-cloud-storage

Usage

Reference any of the existing storage adapters for guidance on how this should be structured. Create an adapter following the GeneratedAdapter interface. Then, pass the adapter to the cloudStorage plugin.

1
export interface GeneratedAdapter {
2
/**
3
* Additional fields to be injected into the base collection and image sizes
4
*/
5
fields?: Field[]
6
/**
7
* Generates the public URL for a file
8
*/
9
generateURL?: GenerateURL
10
handleDelete: HandleDelete
11
handleUpload: HandleUpload
12
name: string
13
onInit?: () => void
14
staticHandler: StaticHandler
15
}
1
import { buildConfig } from 'payload'
2
import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'
3
4
export default buildConfig({
5
plugins: [
6
cloudStorage({
7
collections: {
8
'my-collection-slug': {
9
adapter: theAdapterToUse, // see docs for the adapter you want to use
10
},
11
},
12
}),
13
],
14
// The rest of your config goes here
15
})

Plugin options

This plugin is configurable to work across many different Payload collections. A * denotes that the property is required.

OptionTypeDescription
collections *Record<string, CollectionOptions>Object with keys set to the slug of collections you want to enable the plugin for, and values set to collection-specific options.
enabledbooleanTo conditionally enable/disable plugin. Default: true.

Collection-specific options

OptionTypeDescription
adapter *AdapterPass in the adapter that you'd like to use for this collection. You can also set this field to null for local development if you'd like to bypass cloud storage in certain scenarios and use local storage.
disableLocalStoragebooleanChoose to disable local storage on this collection. Defaults to true.
disablePayloadAccessControltrueSet to true to disable Payload's Access Control. More
prefixstringSet to media/images to upload files inside media/images folder in the bucket.
generateFileURLGenerateFileURLOverride the generated file URL with one that you create.

Payload Access Control

Payload ships with Access Control that runs even on statically served files. The same read Access Control property on your upload-enabled collections is used, and it allows you to restrict who can request your uploaded files.

To preserve this feature, by default, this plugin keeps all file URLs exactly the same. Your file URLs won't be updated to point directly to your cloud storage source, as in that case, Payload's Access control will be completely bypassed and you would need public readability on your cloud-hosted files.

Instead, all uploads will still be reached from the default /collectionSlug/staticURL/filename path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing Access Control in place.

If this does not apply to you (your upload collection has read: () => true or similar) you can disable this functionality by setting disablePayloadAccessControl to true. When this setting is in place, this plugin will update your file URLs to point directly to your cloud host.

Conditionally Enabling/Disabling

The proper way to conditionally enable/disable this plugin is to use the enabled property.

1
cloudStoragePlugin({
2
enabled: process.env.MY_CONDITION === 'true',
3
collections: {
4
'my-collection-slug': {
5
adapter: theAdapterToUse, // see docs for the adapter you want to use
6
},
7
},
8
}),
Next

Email Functionality