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

Option

Description

Default

enabled

Whether or not to enable the plugin

true

collections

Collections to apply the Vercel Blob adapter to

addRandomSuffix

Add a random suffix to the uploaded file name in Vercel Blob storage

false

cacheControlMaxAge

Cache-Control max-age in seconds

365 * 24 * 60 * 60 (1 Year)

token

Vercel 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

Option

Description

Default

enabled

Whether or not to enable the plugin

true

collections

Collections to apply the Azure Blob adapter to

allowContainerCreate

Whether or not to allow the container to be created if it does not exist

false

baseURL

Base URL for the Azure Blob storage account

connectionString

Azure Blob storage connection string

containerName

Azure 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

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

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

Option

Description

Default

token

Token from Uploadthing. Required.

acl

Access control list for files that are uploaded

public-read

logLevel

Log level for Uploadthing

info

fetch

Custom fetch function

fetch

defaultKeyType

Default key type for file operations

fileKey

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.

Option

Type

Description

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.

enabled

boolean

To conditionally enable/disable plugin. Default: true.

Collection-specific options

Option

Type

Description

adapter *

Adapter

Pass 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.

disableLocalStorage

boolean

Choose to disable local storage on this collection. Defaults to true.

disablePayloadAccessControl

true

Set to true to disable Payload's Access Control. More

prefix

string

Set to media/images to upload files inside media/images folder in the bucket.

generateFileURL

GenerateFileURL

Override 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