1.0.2 • Published 5 years ago

egg-qiniu-upload-token v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

egg-qiniu-upload

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-qiniu-upload-token --save-dev

Usage

// {app_root}/config/plugin.js
exports.qiniu = {
  enable: true,
  package: 'egg-qiniu-upload-token',
};

Configuration

// {app_root}/config/config.default.js
exports.qiniu = {
  // I ussually set the key into `~/.zshrc`, and I can get the value via `process.env.key`, It's very safe~
  ak: 'your access key',
  sk: 'your secret key',
  bucket: 'yout bucket',
  baseUrl: 'your base url',
  zone: 'your zone',
  app: true, // default value
  agent: false, //default value
};

see config/config.default.js for more detail, and more detail about qiniu please see the document

Example

upload file to qiniu and return the url and key

// {app_root}/app/service/file.js
async upload2Qiniu(path,realname) {
  const {app} = this

  // do someting what you want to do........

  return await app.qiniu.upload(path, realname)
}
/* return a Objet:
{key:'your key',url:'your public url'}
*/

get the file info by your file's key

// {app_root}/app/servcie/file.js
async info(key) {
  // your should auth the user's passport.
  return await this.app.qiniu.info(key);
}

async info(key) {
  return await this.app.qiniu.token();
}

more function ...

Questions & Suggestions

Please open an issue here.

License

MIT

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago