- Notifications
You must be signed in to change notification settings - Fork2
Tencent COS provider for Strapi
License
yclgkd/strapi-provider-upload-tencent-cloud-storage
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
# using yarnyarn add strapi-provider-upload-tencent-cloud-storage# using npmnpm install strapi-provider-upload-tencent-cloud-storage --save
providerdefines the name of the providerproviderOptionsis passed down during the construction of the provider. It contains the following properties:- SecretId: Tencent Cloud API SecretId
- SecretKey: Tencent Cloud API SecretKey
- Region: Tencent Cloud API Region
- Bucket: Tencent Cloud API Bucket
- ACL: (optional) ACL applied to the uploaded files.
- Expires: (optional) Expiration time of the signed URL. Default value is 360 seconds (6 minutes).
- initOptions: (optional) Options passed to the constructor of the provider. You can find the complete list ofoptions here.
- uploadOptions: (optional) Options passed to the
uploadmethod. You can find the complete list ofoptions here. - CDNDomain: (optional) CDN Accelerated Domain.
- StorageRootPath: (optional) The storage path of the file in the bucket.
See thedocumentation about using a provider for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to thedocumentation about environment variables.
./config/plugins.js or./config/plugins.ts for TypeScript projects:
module.exports=({ env})=>({// ...upload:{config:{provider:"strapi-provider-upload-tencent-cloud-storage",providerOptions:{SecretId:env("COS_SECRET_ID"),SecretKey:env("COS_SECRET_KEY"),Region:env("COS_REGION"),Bucket:env("COS_BUCKET"),},},},// ...});
If your bucket is configured to be private, you will need to set theACL option toprivate in theparams object. This will ensure file URLs are signed.
Note: If you are using a CDN, the URLs will not be signed.
You can also define the expiration time of the signed URL by setting theExpires option in theproviderOptions object. The default value is 360 seconds (6 minutes).
./config/plugins.js or./config/plugins.ts for TypeScript projects:
module.exports=({ env})=>({// ...upload:{config:{provider:"strapi-provider-upload-tencent-cloud-storage",providerOptions:{SecretId:env("COS_SECRET_ID"),SecretKey:env("COS_SECRET_KEY"),Region:env("COS_REGION"),Bucket:env("COS_BUCKET"),ACL:"private",// <= set ACL to private},},},// ...});
Due to the default settings in the Strapi Security Middleware you will need to modify thecontentSecurityPolicy settings to properly see thumbnail previews in the Media Library. You should replacestrapi::security string with the object bellow instead as explained in themiddleware configuration documentation.
./config/middlewares.js or./config/middlewares.ts for TypeScript projects:
module.exports=[// ...{name:"strapi::security",config:{contentSecurityPolicy:{useDefaults:true,directives:{"connect-src":["'self'","https:"],"img-src":["'self'","data:","blob:","market-assets.strapi.io","yourBucketName.cos.yourRegion.myqcloud.com",],"media-src":["'self'","data:","blob:","market-assets.strapi.io","yourBucketName.cos.yourRegion.myqcloud.com",],upgradeInsecureRequests:null,},},},},// ...];
./config/plugins.js or./config/plugins.ts for TypeScript projects:
module.exports=({ env})=>({// ...upload:{config:{provider:"strapi-provider-upload-tencent-cloud-storage",providerOptions:{CDNDomain:"example-cdn-domain.com",// <= CDN Accelerated DomainSecretId:env("COS_SECRET_ID"),SecretKey:env("COS_SECRET_KEY"),Region:env("COS_REGION"),Bucket:env("COS_BUCKET"),},},},// ...});
Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
About
Tencent COS provider for Strapi
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.