nikolvs

payload storage github

by nikolvs
Cloud storage
v3
^3.2.2
MIT

Overview

Summary generated from the README

A storage adapter that saves Payload upload files in a GitHub repository using the GitHub REST API via Octokit. Collections are enabled by slug, optionally with a path prefix, and local storage is automatically disabled for them. It needs the repository owner, repo name, optional branch (default main) and an access token.

Features

  • Per-collection enablement by slug with optional path prefix
  • Automatically disables local storage for enabled collections
  • Configurable repository owner, name and branch
  • Passes Octokit client options such as an auth token
  • Can be toggled on or off with an enabled option

Use cases

  • Keep media uploads versioned inside a GitHub repository instead of local disk
  • Host Payload files on serverless deployments without an object store

From the author

Payload storage adapter for GitHub

Installation

npm i payload-storage-github

9

Stars

1

Forks

0

Open Issues

1 years ago

Last Updated

0

Weekly Downloads

v1.0.1

npm Version

32.8 KB

Unpacked Size

2

Dependencies

GitHub stars

Trends appear after 7 days of data. Daily snapshots have not started yet.

npm weekly downloads

Trends appear after 7 days of data. Daily snapshots have not started yet.

Each point is npm's rolling 7-day download count.

Health Score

35/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/887320325-root.svg)](https://payloaddirectory.dev/plugins/887320325-root)
HTML
<a href="https://payloaddirectory.dev/plugins/887320325-root"><img src="https://payloaddirectory.dev/badge/887320325-root.svg" alt="Payload Directory"></a>
Updated Dec 3, 2024Created Nov 12, 2024Published Dec 3, 2024

README

GitHub Storage for Payload

This package provides a way to use the GitHub REST API to store files with Payload.

Installation

pnpm add payload-storage-github

Usage

  • Configure the collections object to specify which collections should use the GitHub 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.
import { githubStorage } from 'payload-github-storage'
import { Media } from './collections/Media'
import { MediaWithPrefix } from './collections/MediaWithPrefix'

export default buildConfig({
  collections: [Media, MediaWithPrefix],
  plugins: [
    githubStorage({
      collections: {
        [mediaSlug]: true,
        [mediaWithPrefixSlug]: {
          prefix: '/media',
        },
      },

      owner: process.env.GITHUB_REPOSITORY_OWNER,
      repo: process.env.GITHUB_REPOSITORY_NAME,
      branch: process.env.GITHUB_REPOSITORY_BRANCH,

      options: {
        auth: process.env.GITHUB_ACCESS_TOKEN,
      },
    }),
  ],
})

Configuration Options

OptionDescriptionDefault
enabledWhether or not to enable the plugintrue
collectionsCollections to apply the storage to
ownerThe name of the repository owner (GitHub username or organization)
repoThe repository name
branchWhich branch to upload/read files"main"
optionsOctokit client configuration. See Docs

Similar plugins