DrMint

payloadcms sftp storage

by DrMint
Cloud storage
v?

Overview

Summary generated from the README

Adds an SFTP adapter for the Payload cloud-storage plugin, built on ssh2-sftp-client. Uploads are sent to a remote server over SSH and placed in a subfolder named after the collection slug. It is configured per collection with connection options, a destination root path and a public endpoint.

Features

  • Stores collection uploads on a remote server over SFTP
  • Authenticates with a private key and passphrase or a password
  • Supports a custom port and an absolute destination root folder
  • Places files in a subfolder named after the collection slug
  • Deletes the remote file when the document is deleted

Use cases

  • Store video or media uploads on your own server instead of a cloud object store
  • Serve uploaded files from an existing web host reachable by SFTP

From the author

SFTP adapter for Payload CMS's plugin-cloud-storage plugin

Installation

npm i payloadcms-sftp-storage

2

Stars

0

Forks

0

Open Issues

2 years ago

Last Updated

11

Weekly Downloads

v1.0.1

npm Version

6.6 KB

Unpacked Size

3

Dependencies

GitHub stars

20 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20262
Dec 4, 20262
Dec 3, 20262
Dec 2, 20262
Dec 1, 20262
Nov 30, 20262
Nov 29, 20262
Nov 28, 20262
Nov 27, 20262
Nov 26, 20262
Nov 25, 20262
Nov 24, 20262
Nov 23, 20262
Nov 22, 20262
Nov 21, 20262
Nov 20, 20262
Nov 19, 20262
Nov 18, 20262
Nov 17, 20262
Nov 16, 20262
Nov 15, 20262
Nov 14, 20262
Nov 13, 20262
Nov 12, 20262
Nov 11, 20262
Nov 10, 20262
Nov 9, 20262
Nov 8, 20262
Nov 7, 20262
Nov 6, 20262
Nov 5, 20262
Nov 4, 20262
Nov 3, 20262
Nov 2, 20262
Nov 1, 20262
Oct 31, 20262
Oct 30, 20262
Oct 29, 20262
Oct 28, 20262
Oct 27, 20262
Oct 26, 20262
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20262
Oct 21, 20262
Oct 20, 20262
Oct 19, 20262
Oct 18, 20262
Oct 17, 20262
Oct 16, 20262
Oct 15, 20262
Oct 14, 20262
Oct 13, 20262
Oct 12, 20262
Oct 11, 20262
Oct 10, 20262
Oct 9, 20262
Oct 8, 20262
Oct 7, 20262
Oct 6, 20262
Oct 5, 20262
Oct 4, 20262
Oct 3, 20262
Oct 2, 20262
Oct 1, 20262
Sep 30, 20262
Sep 29, 20262
Sep 28, 20262
Sep 27, 20262
Sep 26, 20262
Sep 25, 20262
Sep 24, 20262
Sep 23, 20262
Sep 22, 20262
Sep 21, 20262
Sep 20, 20262
Sep 19, 20262
Sep 18, 20262
Sep 17, 20262
Sep 16, 20262
Sep 15, 20262
Sep 14, 20262
Sep 13, 20262
Sep 12, 20262
Sep 11, 20262
Sep 10, 20262
Sep 9, 20262
Sep 8, 20262
Sep 7, 20262
Sep 6, 20262
npm weekly downloads

11+2 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202611
Dec 4, 20267
Dec 3, 20269
Dec 2, 202610
Dec 1, 202611
Nov 30, 202611
Nov 29, 202612
Nov 28, 202612
Nov 27, 202618
Nov 26, 202620
Nov 25, 202622
Nov 24, 202620
Nov 23, 202620
Nov 22, 202651
Nov 21, 202662
Nov 20, 202660
Nov 19, 202661
Nov 18, 202663
Nov 17, 202664
Nov 16, 202664
Nov 15, 202689
Nov 14, 202690
Nov 13, 2026100
Nov 12, 2026101
Nov 11, 202696
Nov 10, 2026100
Nov 9, 2026102
Nov 8, 202644
Nov 7, 202661
Nov 6, 202660
Nov 5, 202653
Nov 4, 202678
Nov 3, 202673
Nov 2, 202675
Nov 1, 202676
Oct 31, 202647
Oct 30, 202632
Oct 29, 202632
Oct 28, 20267
Oct 27, 20269
Oct 26, 20265
Oct 25, 20265
Oct 24, 20266
Oct 23, 20266
Oct 22, 20267
Oct 21, 20267
Oct 20, 20265
Oct 19, 20264
Oct 18, 20262
Oct 17, 20262
Oct 16, 20264
Oct 15, 20268
Oct 14, 202610
Oct 13, 202610
Oct 12, 202610
Oct 11, 202611
Oct 10, 202610
Oct 9, 20268
Oct 8, 20263
Oct 7, 20261
Oct 6, 20262
Oct 5, 20262
Oct 4, 20263
Oct 3, 20264
Oct 2, 20268
Oct 1, 20269
Sep 30, 20269
Sep 29, 202610
Sep 28, 202610
Sep 27, 202612
Sep 26, 202618
Sep 25, 202616
Sep 24, 202615
Sep 23, 202617
Sep 22, 202617
Sep 21, 202618
Sep 20, 202615
Sep 19, 20268
Sep 18, 20269
Sep 17, 202612
Sep 16, 202611
Sep 15, 20269
Sep 14, 202610
Sep 13, 20269
Sep 12, 202614
Sep 11, 202611
Sep 10, 20268
Sep 9, 20269
Sep 8, 20269
Sep 7, 20269
Sep 6, 20269

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

Health Score

32/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/782753635-root.svg)](https://payloaddirectory.dev/plugins/782753635-root)
HTML
<a href="https://payloaddirectory.dev/plugins/782753635-root"><img src="https://payloaddirectory.dev/badge/782753635-root.svg" alt="Payload Directory"></a>
Updated Apr 6, 2024Created Apr 6, 2024Published Apr 6, 2024

README

PayloadCMS SFTP Storage Adapter

SFTP adapter for Payload CMS's plugin-cloud-storage plugin

This adapter uses ssh2-sftp-client to handle the SSH connection and SFTP operations.

Usage

Let's say we have a Videos collection (which slug is "videos") and we want to store the uploads on a third-party remote storage using SFTP.

At the top of your payload.config.ts file, add the following:

import { sftpAdapter } from "payloadcms-sftp-storage";

Then within the buildConfig add the following:

plugins: [
  cloudStorage({
    collections: {
      videos: {
          adapter: sftpAdapter({
          connectOptions: {
              host: "domain.com",
              username: "userName",
              privateKey: process.env.SFTP_PRIVATE_KEY, // See bellow how to add a privatekey in .env file
              passphrase: 'a pass phrase for the private key'

              // Instead of a private key you can also use a password:
              // password: "mypassword",

              // You may set a custom port (default: 22)
              // port: 2207,
          },
          destinationPathRoot: "/absolute/path/to/destination/root/folder",
          publicEndpoint: "https://domain.com",
        }),
        disableLocalStorage: true,
        disablePayloadAccessControl: true,
      },
    },
  }),
],

If we upload a video file name "my-video.mp4", the file will be uploaded at destinationPathRoot, in a subfolder named "videos" (because this is the slug of the collection) as a file with the same name as the original "my-video.mp4". In this example, the path of the transfered file will be /absolute/path/to/destination/root/folder/videos/my-video.mp4, and its public address will be https://domain.com/videos/my-video.mp4

Beware: when deleting an entry, the file will also be deleted on the remote storage. Also, if a file "my-video.mp4" already exists, and we try to upload another file with the same name, the original file will be overwritten.

About the Private Key

It's a bit tedious to use a private key. You can't use fs within PayloadCMS config file without resorting to some webpack shenanigans. So instead, here's how to store the private key in a .env variable:

Run this command:

echo "SFTP_PRIVATE_KEY=\"`sed -E 's/$/\\\n/g' /path/to/my_private_key`\"" >> /path/to/.env

Then open your .env file and edit the variable into a single line.

Tags

Similar plugins