@axolo/egg-cos

0.0.7 • Public • Published

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.

License

MIT

Package Sidebar

Install

npm i @axolo/egg-cos

Weekly Downloads

36

Version

0.0.7

License

MIT

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • axolo