Giter VIP home page Giter VIP logo

strapi-provider-upload-cloud-object-storage's Introduction

A provider for strapi server to upload file to Tencent COS.

Installation

npm install strapi-provider-upload-cloud-object-storage --save

Usage

strapi v4, See example below for ./config/plugins.js

export default ({ env }) => ({
    upload: {
      config: {
        provider: 'strapi-provider-upload-cloud-object-storage', // the full name
        providerOptions: {
          appId: env('COS_APPID'),
          secretId: env('COS_SECRET_ID'), 
          secretKey: env('COS_SECRET_KEY'),
          region: env('COS_REGION'),
          bucket: env('COS_BUCKET'),
          basePath: env('COS_BASE_PATH'),
        },
      },
    }
});

Provider Options

Property Type Value
COS_APPID string tencent appid
COS_SECRET_ID string tencent secreted id
COS_SECRET_KEY string tencent secreted key
COS_REGION string cosregion
COS_BUCKET string bucket name
COS_BASE_PATH string path to store the file, e.g. strapi-cms/

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

export default ({ env }) => { return [
  // ...
  { 
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": [
            "'self'",
            "data:",
            "blob:",
            `${env('COS_BUCKET')}-${env('COS_APPID')}.cos.${env('COS_REGION')}.myqcloud.com` 
          ],
          "media-src": [
            "'self'", 
            "data:",
            "blob:", 
            `${env('COS_BUCKET')}-${env('COS_APPID')}.cos.${env('COS_REGION')}.myqcloud.com`
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];
}

Reference

strapi-provider-upload-cloud-object-storage's People

Contributors

sinkhaha avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.