Announcing the official Cloud Storage Plugin

Published On
Announcing the official Cloud Storage Plugin
Announcing the official Cloud Storage Plugin

Payload just released its official Cloud Storage plugin, with support for file storage in AWS S3 and Azure Blob Storage out of the box.

Payload plugins can be insanely powerful, and they're trivial to write thanks to Payload's code-first, config-based nature. We've already seen an impressive array of community plugins, including a few great cloud storage solutions from Richard VanBergen and Alex Bechmann. We're extremely thankful for our community, especially Richard and Alex in regards to their help with cloud storage.

Over the past few months, enterprise clients of ours have asked quite a few times for us to build an officially supported cloud storage plugin, so that all files uploaded to Payload can be stored in the cloud storage provider of their choice. Of course, by default, Payload allows you to store uploads on your own server, but at scale, you might want to offload them to a CDN-backed service for performance and scalability reasons.

So we built a robust, officially supported cloud storage plugin. It's extremely powerful and comes out-of-the-box with Amazon S3 and Azure Blob Storage support. The plugin is built with an adapter-based approach, so you can use it with any cloud storage provider that you wish.

Usage

Installing and using the plugin is easy. Here's what it looks like to use the S3 adapter:

1
import { buildConfig } from "payload/config";
2
import Media from "./collections/Media";
3
import { cloudStorage } from "@payloadcms/plugin-cloud-storage";
4
import { s3Adapter } from "@payloadcms/plugin-cloud-storage/s3";
5
6
export default buildConfig({
7
collections: [Media],
8
plugins: [
9
// Pass the plugin to Payload
10
cloudStorage({
11
collections: {
12
// Enable cloud storage for Media collection
13
media: {
14
// Create the S3 adapter
15
adapter: s3Adapter({
16
config: {
17
endpoint: process.env.S3_ENDPOINT,
18
credentials: {
19
accessKeyId: process.env.S3_ACCESS_KEY_ID,
20
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
21
},
22
},
23
bucket: process.env.S3_BUCKET,
24
}),
25
},
26
},
27
}),
28
],
29
});

With this plugin, instead of saving files locally to your server, Payload will ship off all uploads, including all automatically resized images, straight to your cloud storage provider.

Adapter-based Implementation

The plugin is built on a simple, yet powerful adapter-based implementation. This means it can be used for any type of cloud storage you need. Out of the box, it comes with Azure Blob Storage and AWS S3 support, but you can easily write your own adapter(s) to host your uploads wherever you need.

Access Control

Payload comes with built-in access control for all uploads. It works seamlessly by re-using your upload-enabled collection's read access control—meaning you can easily restrict who can access which uploads that are stored in your site. This is super powerful in lots of cases, and is a specific strength of Payload over other headless CMS.

Imagine if you had a public Customers collection, and your customers could upload sensitive documents to attach to their profile. You may only want certain users to be able to view these sensitive documents - i.e. admins or the customers themselves. But most people should be denied access.

With Payload, this is built-in. And this plugin fully supports this functionality, so you can build powerful and elegant access control patterns to protect your files—even when they're hosted on your cloud provider.

Get started

Get started by installing the plugin in your Payload app with the following command:

1
yarn add @payloadcms/plugin-cloud-storage

From there, check out the docs to learn about all the things you can do.

Give Payload a star

Request a Plugin

Need a plugin to be created? Join our Discord server and post in the #plugins channel. The Payload team might create it for you, or maybe a community member can help!

Get started in one line

If you haven't yet given the CMS a shot, you can get started free with one command:

1
npx create-payload-app