Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

@payloadcms/plugin-cloud-storage

Package Overview
Dependencies
Maintainers
2
Versions
1195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@payloadcms/plugin-cloud-storage

The official cloud storage plugin for Payload CMS

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
134K
-14.98%
Maintainers
2
Weekly downloads
 
Created
Source

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.16 or 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:

  • Azure Blob Storage
  • AWS S3-style Storage

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.

OptionDescription
collections *Array of collection-specific options to enable the plugin for.

Collection-specific options:

OptionDescription
slug *The collection slug to extend.
adapter *Pass in the adapter that you'd like to use for this collection.
disableLocalStorageChoose to disable local storage on this collection. Defaults to true.

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 plugin

S3 Adapter

To use the S3 adapter, you need to have @aws-sdk/client-s3 isntalled in your project dependencies. To do so, run yarn add @aws-sdk/client-s3.

From there, create the adapter, passing in all of its required properties:

import { s3Adapter } from '@payloadcms/plugin-cloud-storage';

const adapter = s3Adapter({
  config: {
    endpoint: process.env.S3_ENDPOINT,
    credentials: {
      accessKeyId: process.env.S3_ACCESS_KEY_ID,
      secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
    }
  },
  bucket: process.env.S3_BUCKET,
})

// Now you can pass this adapter to the plugin

Local development

For instructions regarding how to develop with this plugin locally, click here.

Questions

Please contact Payload with any questions about using this plugin.

Credit

This plugin was created with significant help, and code, from Alex Bechmann and Richard VanBergen. Thank you!!

FAQs

Package last updated on 07 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts