1.0.0 • Published 8 months ago
strapi-provider-upload-cloud-object-storage v1.0.0
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
1.0.0
8 months ago