An SFTP adapter for the Payload cloud-storage plugin that stores collection uploads on a remote server over SSH. It uses ssh2-sftp-client for the connection and file operations. Configure it per collection with connection options, a destination root path and a public endpoint.
SFTP adapter for Payload CMS's plugin-cloud-storage plugin
Installation
npm i payloadcms-sftp-storage2
Stars
0
Forks
0
Open Issues
2 years ago
Last Updated
0
Weekly Downloads
v1.0.1
npm Version
6.6 KB
Unpacked Size
3
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
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
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/782753635-root)<a href="https://payloaddirectory.dev/plugins/782753635-root"><img src="https://payloaddirectory.dev/badge/782753635-root.svg" alt="Payload Directory"></a>README
SFTP adapter for Payload CMS's plugin-cloud-storage plugin
This adapter uses ssh2-sftp-client to handle the SSH connection and SFTP operations.
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.
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.
cloud storage
Official Payload plugin for storing uploads in third-party cloud storage through a pluggable adapter interface
100426.0k/wk45.4kv3
payload storage bunny
Storage adapter that keeps Payload uploads and video in Storage and Stream
821.6k/wk60v4
payload storage cloudinary
Cloudinary storage adapter that moves Payload uploads to Cloudinary with transformations, folders and private files
550/wk7v3
payload storage file explorer
Browse and manage S3-compatible bucket files from an admin view in Payload
460/wk12v3
payload nextcloud
Nextcloud storage adapter for Payload uploads over WebDAV with optional public share links
390/wk2v3
payload cloudinary plugin
Upload Payload media files to Cloudinary
390/wk77v2