Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Strapi Upload Provider for Digital Ocean Spaces. This provider will upload to the space using the AWS S3 API.

License

Notifications You must be signed in to change notification settings

LYL-Radio/strapi-provider-upload-do

 
 

Repository files navigation

@lyl-radio/strapi-provider-upload-do

Resources

Links

Installation

using yarn

yarn add @lyl-radio/strapi-provider-upload-do

using npm

npm install @lyl-radio/strapi-provider-upload-do --save

Configuration

See the documentation about using a provider for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to the documentation about environment variables.

Provider Configuration

./config/plugins.js

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: '@lyl-radio/strapi-provider-upload-do',
      providerOptions: {
        key: env('DO_SPACE_ACCESS_KEY'),
        secret: env('DO_SPACE_SECRET_KEY'),
        endpoint: env('DO_SPACE_ENDPOINT'),
        space: env('DO_SPACE_BUCKET'),
        directory: env('DO_SPACE_DIRECTORY'),
        cdn: env('DO_SPACE_CDN'),
      },
      actionOptions: {
        upload: {},
        uploadStream: {},
        delete: {},
      },
    },
  },
  // ...
});

Security Middleware Configuration

Due to the default settings in the Strapi Security Middleware you will need to modify the contentSecurityPolicy settings to properly see thumbnail previews in the Media Library. You should replace strapi::security string with the object bellow instead as explained in the middleware configuration documentation.

./config/middlewares.js

module.exports = [
  // ...
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': [
            "'self'",
            'data:',
            'blob:',
            'yourBucketName.yourRegion.digitaloceanspaces.com',
            'yourBucketName.yourRegion.cdn.digitaloceanspaces.com',
          ],
          'media-src': [
            "'self'",
            'data:',
            'blob:',
            'yourBucketName.yourRegion.digitaloceanspaces.com',
            'yourBucketName.yourRegion.cdn.digitaloceanspaces.com',
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];

You can also add your custom CDN subdomain to img-src and media-src directives.

About

Strapi Upload Provider for Digital Ocean Spaces. This provider will upload to the space using the AWS S3 API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 100.0%