qiniu.js
564 Bytes
/**
* 七牛上传
* @author: chenfeng <feng.chen@yoho.cn>
* @date: 29/06/2017
*/
const qiniu = require('qiniu');
const qiniuConfig = global.yoho.config.qiniu;
function getToken(req, res) {
let mac = new qiniu.auth.digest.Mac(qiniuConfig.ACCESS_KEY, qiniuConfig.SECRET_KEY);
let options = {
scope: qiniuConfig.BUCKET_NAME,
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
res.json({
code: 200,
uptoken: uploadToken
});
}
module.exports = {
getToken
};