qiniu.js
775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/8/19
*/
'use strict';
const qn = require('qn');
const Promise = require('bluebird');
const _ = require('lodash');
const config = {
accessKey: 'cY9B5ZgON_7McTS5zV5nTeRyQ98MOcVD7W4eGVbE',
secretKey: 'RduqgmK7cAtaQvdIa1ax_zzmMsnv9ac-Ka0uF6wG',
origin: 'http://cdn.yoho.cn',
bucket: 'yohocdn'
};
const _default = (params) => {
let finalConfig = config;
if (params) {
_.assign(finalConfig, params);
}
return Promise.promisifyAll(
qn.create(finalConfig)
);
}
_default.key = function(key) {
let _conifg = _.clone(config);
_conifg.bucket = _conifg.bucket + ":" + key;
return Promise.promisifyAll(qn.create(_conifg));
};
module.exports = _default;