const qiniu = require('qiniu')
// 需要填写你的 Access Key 和 Secret Key
var accessKey = 'lASuKnvKXJrbrBY4bAyn877lW3GjrwsVXN2-DVZG'
var secretKey = 'fsfC7V-dzTHF49TLk-YuSywTVClHbdoOY7lwPgLt'
var mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
var options = {
scope: 'bearxcq',
};
var putPolicy = new qiniu.rs.PutPolicy(options);
var uploadToken = putPolicy.uploadToken(mac);
var config = new qiniu.conf.Config();
config.zone = qiniu.zone.Zone_z2;
var localFile = "../1441954332s.png";
var formUploader = new qiniu.form_up.FormUploader(config);
var putExtra = new qiniu.form_up.PutExtra();
var key = 'koo.png';
// 文件上传
formUploader.putFile(uploadToken, key, localFile, putExtra, function (respErr,
respBody, respInfo) {
if (respErr) {
throw respErr;
}
if (respInfo.statusCode == 200) {
console.log('成功');
console.log(respInfo);
} else {
console.log('失败');
console.log(respInfo.statusCode);
console.log(respBody);
}
});