JSPM

strapi-provider-upload-dos-s3

5.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q67320F
  • License MIT

Strapi Provider for Digital Ocean Spaces

Package Exports

  • strapi-provider-upload-dos-s3
  • strapi-provider-upload-dos-s3/lib/index.js

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 (strapi-provider-upload-dos-s3) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Strapi Upload Provider for Digital Ocean Spaces

This provider will upload to the space using the AWS S3 API

+ Compatible with version 4 of STRAPI (upgraded)

Parameters

  • key : Space access key
  • secret : Space access secret
  • endpoint : Base URL of the space (e.g. fra.digitaloceanspaces.com)
  • space : Name of the space in the Digital Ocean panel.
  • directory : Name of the sub-directory you want to store your files in. (Optional - e.g. /example)
  • cdn : CDN Endpoint - URL of the cdn of the space (Optional - e.g. cdn.example.com)
  • hash : Configures the hash algorithm that is used for URLs. (Optional - default md5)

How to use

  1. Install this package using npm or yarn
npm i strapi-provider-upload-dos-s3
yarn add strapi-provider-upload-dos-s3
  1. Create config in ./config/plugins with content (create if not exist (plugins.js))
module.exports = {
  upload: {
    config: {
      provider: "strapi-provider-upload-dos-s3",
      providerOptions: {
        key: process.env.DO_SPACE_ACCESS_KEY,
        secret: process.env.DO_SPACE_SECRET_KEY,
        endpoint: process.env.DO_SPACE_ENDPOINT,
        space: process.env.DO_SPACE_BUCKET,
        directory: process.env.DO_SPACE_DIRECTORY,
        cdn: process.env.DO_SPACE_CDN,
        hash: process.env.DO_SPACE_HASH
      },
    },
  },
};
  1. Create .env and add to them
DO_SPACE_ACCESS_KEY
DO_SPACE_SECRET_KEY
DO_SPACE_ENDPOINT
DO_SPACE_BUCKET
DO_SPACE_DIRECTORY
DO_SPACE_CDN
DO_SPACE_HASH

with values obtained from tutorial:

https://www.digitalocean.com/community/tutorials/how-to-create-a-digitalocean-space-and-api-key

Parameter DO_SPACE_DIRECTORY, DO_SPACE_CDN and DO_SPACE_HASH are optional and you can ommit them both in .env and settings.

Modify the CSP roules and define the source

config/middlewares.js

module.exports = [
  "strapi::errors",
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": [
            "'self'",
            "data:",
            "blob:",
            "*.digitaloceanspaces.com"
          ],
          "media-src": ["'self'", "data:", "blob:"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  "strapi::cors",
  "strapi::poweredBy",
  "strapi::logger",
  "strapi::query",
  "strapi::body",
  "strapi::favicon",
  "strapi::public",
];

Resources