Egg's tencent-oss plugin.
$ npm i tencent-oss --save
Change {app_root}/config/plugin.js
to enable my-tencent-oss
plugin:
exports.tencentOss = {
enable: true,
package: 'my-tencent-oss',
};
// {app_root}/config/config.default.js
config.tencentOss = {
clients: {
cos1: {
credential: {
SecretId: '',
SecretKey: ''
}
},
cos2: {
sts: {
clientConfig: {
credential: {
secretId: '',
secretKey: ''
},
region: "ap-guangzhou",
profile: {
httpProfile: {
endpoint: "sts.tencentcloudapi.com",
},
},
},
"Name": "access",
Policy: {
"version": "2.0",
"statement": [
{
"effect": "allow",
"action": [
"cos:PutObject",
"cos:GetObject",
"cos:HeadObject",
"cos:OptionsObject",
"cos:ListParts",
"cos:GetObjectTagging"
],
"resource": "*"
}
]
}
}
}
}
};
//configure
const oss=require("tencent-oss");
app.use(new oss({
cos1: {
credential: {
SecretId: '',
SecretKey: ''
}
}
}))
//use
req.tencentOSS.get("cos1")
Please open an issue here.