JSPM

keystone-storage-adapter-dropbox

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q22676F
  • License MIT

Dropbox storage adapter for keystonejs

Package Exports

  • keystone-storage-adapter-dropbox

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (keystone-storage-adapter-dropbox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Dropbox storage adapter for keystonejs

Usage

Configure the storage adapter:

var storage = new keystone.Storage({
  adapter: require('keystone-storage-adapter-dropbox'),
  dropbox: {
      accessToken: process.env.DROPBOX_ACCESS_TOKEN,// your dropbox-app access token
      path: process.env.DROPBOX_PATH + '/uploads',// any path
  },
  path: process.env.DROPBOX_PATH + '/uploads',
  schema: {
    filename: true,
    path_display: true,
    path: true,
    id: true,
    url: true,
    originalname: true,   // the original (uploaded) name of the file; useful when filename generated
  },
});

Then use it as the storage provider for a File field:

File.add({
  name: { type: String },
  file: { type: Types.File, storage: storage },
});

Options:

The adapter requires an additional s3 field added to the storage options. It accepts the following values:

  • accessToken: (required) Dropbox app access token.

  • path: Storage path inside the app folder.

Tips

  • Delete file from dropbox if delete from db

        Documents.schema.post('remove', async function (doc) {
            return storage.removeFile(doc.file, () => {
        
            });
        });

License

Licensed under the standard MIT license. See LICENSE.