Providers

Certain plugins can be extended via the installation and configuration of additional providers.

Providers add an extension to the core capabilities of the plugin, for example to upload media files to AWS S3 instead of the local server, or using Amazon SES for emails instead of Sendmail.

Only the Upload and Email plugins are currently designed to work with providers.

Upload

官方支援的plugin已有教學[[99. Upload(Media Library)#AWS S3]]

Creating providers

To implement your own custom provider you must create a Node.js module.

1. Create a package.json file

# package.json
{
  "name": "test-module",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

2. Develop provider

export default {
  init(providerOptions) {
    // init your provider if necessary

    return {
      upload(file) {
        // upload the file in the provider
        // file content is accessible by `file.buffer`
      },
      uploadStream(file) {
        // upload the file in the provider
        // file content is accessible by `file.stream`
      },
      delete(file) {
        // delete the file in the provider
      },
    };
  },
};

3. npm install

  1. Create a providers folder under root application
  2. Create your provider (e.g. ./providers/strapi-provider-upload-<provider>)
  3. Edit package.json under root application to link provider
    {
      ...
      "dependencies": {
     ...
     "strapi-provider-<plugin>-<provider>": "file:providers/strapi-provider-<plugin>-<provider>",
     ...
      }
    }
    
  4. Update your ./config/plugins.js file to configure the provider.
  5. run yarn install or npm install

Email

(TBC)