egg-qiniu-upload
v1.1.4
Published
upload file to qiniu plugin for egg-framework, based on qiniu
Downloads
15
Readme
egg-qiniu-upload
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.