payloadcms-ftp-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

PayloadCMS FTP Storage Adapter

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

This adapter uses basic-ftp to handle the FTP 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 FTP.

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

import { ftpAdapter } from "payloadcms-ftp-storage";

Then within the buildConfig add the following:

plugins: [
  cloudStorage({
    collections: {
      videos: {
          adapter: ftpAdapter({
            host: "ftp.domain.com",
            user: "ftpUser",
            password: "ftpUserPassword",
            secure: true,
            endpoint: "https://domain.com/videos",
        }),
        disableLocalStorage: true,
        disablePayloadAccessControl: true,
      },
    },
  }),
],

If we upload a video file name "my-video.mp4", the file will be uploaded at the home of "ftpUser" at "ftp.domain.com", 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 conclusion, the path of the transfered file will be ~/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.

Readme

Keywords

none

Package Sidebar

Install

npm i payloadcms-ftp-storage

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

5.87 kB

Total Files

5

Last publish

Collaborators

  • dr_mint