0.0.4 • Published 5 years ago
@axolo/egg-cos v0.0.4
egg-cos
Tencent Cloud COS plugin for Egg.js.
Install
npm i @axolo/egg-cos --saveUsage
// {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.