Package Exports
- @payloadcms/plugin-cloud-storage
- @payloadcms/plugin-cloud-storage/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@payloadcms/plugin-cloud-storage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Payload Cloud Storage Plugin
This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store all uploaded media in third-party permanent storage.
Requirements
- Payload version
1.0.16or higher is required
Usage
Install this plugin within your Payload as follows:
import { buildConfig } from 'payload/config';
import path from 'path';
import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
export default buildConfig({
plugins: [
cloudStorage({
collections: [{
slug: 'my-collection-slug',
adapter: theAdapterToUse, // see docs for the adapter you want to use
}]
}),
],
// The rest of your config goes here
});Features
Adapter-based Implementation This plugin supports the following adapters:
However, you can create your own adapter for any third-party service you would like to use.
Plugin options
This plugin is configurable to work across many different Payload collections. A * denotes that the property is required.
| Option | Description |
|---|---|
[collections] * |
Array of collection-specific options to enable the plugin for. |
Collection-specific options
| Option | Description |
|---|---|
[slug] * |
The collection slug to extend. |
[disableLocalStorage] |
Choose to disable local storage on this collection. Defaults to true. |
[adapter] |
Pass in the adapter that you'd like to use for this collection. |
Azure Blob Storage Adapter
To use the Azure Blob Storage adapter, you need to have @azure/storage-blob installed in your project dependencies. To do so, run yarn add @azure/storage-blob.
From there, create the adapter, passing in all of its required properties:
import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage';
const adapter = azureBlobStorageAdapter({
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
})
// Now you can pass this adapter to the pluginImportant: make sure you have all of the above environment variables filled out and that they reflect your Azure blob storage configuration.
Local sandbox & plugin development
This repository includes a local development environment for local testing and development of this plugin. To run the local sandbox, follow the instructions below.
- Make sure you have Node and a MongoDB to work with
- Clone the repo
yarnin both the root folder of the repo, and the./devfoldercdinto./devand runcp .env.example .envto create an.envfile- Open your newly created
./dev/.envfile and completely fill out each property - Run
yarn devwithin the/devfolder - Open
http://localhost:3000/adminin your browser
Questions
Please contact Payload with any questions about using this plugin.