GithubHelp home page GithubHelp logo

raoul1996 / egg-qiniu-upload Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 2.0 79 KB

upload file to qiniu plugin for egg-framework, based on qiniu node SDK

License: MIT License

JavaScript 100.00%
egg-plugin eggjs egg qiniu qiniu-sdk qiniu-uploader

egg-qiniu-upload's Introduction

egg-qiniu-upload

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

Install

$ npm i egg-qiniu-upload --save

Usage

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

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);
}

more function ...

Questions & Suggestions

Please open an issue here.

License

MIT

egg-qiniu-upload's People

Contributors

raoul1996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lymanlai wuxushun

egg-qiniu-upload's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.