Files
payloadcms/packages/storage-vercel-blob
Alessio Gravili 1038e1c228 chore: move to eslint v9 (#7041)
- Upgrades eslint from v8 to v9
- Upgrades all other eslint packages. We will have to do a new
full-project lint, as new rules have been added
- Upgrades husky from v8 to v9
- Upgrades lint-staged from v14 to v15
- Moves the old .eslintrc.cjs file format to the new eslint.config.js
flat file format.

Previously, we were very specific regarding which rules are applied to
which files. Now that `extends` is no longer a thing, I have to use
deepMerge & imports instead.

This is rather uncommon and is not a documented pattern - e.g.
typescript-eslint docs want us to add the default typescript-eslint
rules to the top-level & then disable it in files using the
disable-typechecked config.

However, I hate this opt-out approach. The way I did it here adds a lot
of clarity as to which rules are applied to which files, and is pretty
easy to read. Much less black magic

## .eslintignore

These files are no longer supported (see
https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files).
I moved the entries to the ignores property in the eslint config. => one
less file in each package folder!
2024-07-09 09:50:37 -04:00
..

Vercel Blob Storage for Payload

This package provides a simple way to use Vercel Blob storage with Payload.

NOTE: This package removes the need to use @payloadcms/plugin-cloud-storage as was needed in Payload 2.x.

Installation

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.
import { vercelBlobStorage } from '@payloadcms/storage-vercel-blob'
import { Media } from './collections/Media'
import { MediaWithPrefix } from './collections/MediaWithPrefix'

export default buildConfig({
  collections: [Media, MediaWithPrefix],
  plugins: [
    vercelBlobStorage({
      enabled: true, // Optional, defaults to true
      // Specify which collections should use Vercel Blob
      collections: {
        [Media.slug]: true,
        [MediaWithPrefix.slug]: {
          prefix: 'my-prefix',
        },
      },
      // Token provided by Vercel once Blob storage is added to your Vercel project
      token: process.env.BLOB_READ_WRITE_TOKEN,
    }),
  ],
})
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 ''