Skip to content
KeystoneJS LogoKeystoneJSv5

File Adapters

The File field type can support files hosted in a range of different contexts, e.g. in the local filesystem, or on a cloud based file server.

Different contexts are supported by different file adapters. This package contains the built-in file adapters supported by KeystoneJS.

LocalFileAdapter

Usage

const { LocalFileAdapter } = require('@keystonejs/file-adapters');

const fileAdapter = new LocalFileAdapter({
  /*...config */
});

Config

OptionTypeDefaultDescription
srcStringRequiredThe path where uploaded files will be stored on the server.
pathStringValue of srcThe path from which requests for files will be served from the server.
getFilenamefunctionsnullFunction taking a { id, originalFilename } parameter. Should return a name for the uploaded file on disk.

Note: src and path may be the same.

CloudinaryFileAdapter

const { CloudinaryAdapter } = require('@keystonejs/file-adapters');

const fileAdapter = new CloudinaryAdapter({
  /*...config */
});
OptionTypeDefaultDescription
cloudNameStringRequired
apiKeyStringRequired
apiSecretStringRequired
folderStringundefined

Have you found a mistake, something that is missing, or could be improved on this page? Please edit the Markdown file on GitHub and submit a PR with your changes.

Edit Page