Skip to content
KeystoneJS LogoKeystoneJS

File

Support files hosted in a range of different contexts, e.g. in the local filesystem, or on a cloud based file server.

Important: As of this writing (April 2020), an upstream issue with apollo-server's dependencies can cause a server crash when using this field (regardless of adapter) with Node 13 only. To work around this, use Node 12 or below or add the following to your package.json:

package.json
JS
"resolutions": {
  "graphql-upload": "^10.0.0"
}

You can track this issue here.

Usage

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

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

keystone.createList('Applicant', {
  fields: {
    file: {
      type: File,
      adapter: fileAdapter,
      isRequired: true,
    },
  },
});

Config

OptionTypeDefaultDescription
adapterObjectRequiredSee the File Adapters page for available adapters.
isRequiredBooleanfalseDoes this field require a value?

On this page

  • Usage
  • Config
Edit on GitHub