@axolo/egg-cos
v0.0.7
Published
Tencent Cloud COS plugin for Egg.js.
Downloads
139
Maintainers
Readme
egg-cos
Tencent Cloud COS SDK plugin for Egg.js.
Install
npm i @axolo/egg-cos --save
Usage
// {app_root}/config/plugin.js
exports.cos = {
enable: true,
package: '@axolo/egg-cos',
};
Configuration
// {app_root}/config/config.default.js
exports.cos = {
SecretId: 'COS_SECRETID',
SecretKey: 'COS_SECRETKEY',
Bucket: 'BUCKET-APPID',
Region: 'COS_REGION', // e.g ap-shanghai
};
see config/config.default.js for more detail.
Example
Get file signature url from cos like http://localhost:7001/cos/logo.png
.
const Controller = require('egg').Controller;
class CosController extends Controller {
async show() {
const { app, ctx } = this;
const { id } = ctx.params;
const res = await app.cos.signatureUrl(id);
ctx.body = res;
}
}
module.exports = CosController;
Questions & Suggestions
Please open an issue here.