nodejs怎么做cdn分发

时间:2022-12-06 01:18

nodejs怎么做cdn分发

nodejs做cdn分发的示例:

cdn带宽流量nodejs接口实现代码:

varqiniu=require('qiniu');

varrequest=require('request');

varurllib=require('urllib');

qiniu.conf.ACCESS_KEY='**';

qiniu.conf.SECRET_KEY='**';

varurl='/v2/tune/bandwidth\n';

varaccessToken=qiniu.util.generateAccessToken(url,'');

console.log(accessToken);

urllib.request('http://fusion.qiniuapi.com/v2/tune/bandwidth',{

method:'POST',

headers:{

'Content-Type':'application/json',

'Authorization':accessToken,

},

data:{

'startDate':'2016-07-01',

'endDate':'2016-07-03',

'granularity':'5min',

'domains':'302-test.songfei.echohu.top'

}

},function(err,data,res){

if(err){

throwerr;//youneedtohandleerror

}

console.log(res.statusCode);

console.log(res.headers);

//dataisBufferinstance

console.log(data.toString())

});

varrequest=require('request');

varurllib=require('urllib');

qiniu.conf.ACCESS_KEY='**';

qiniu.conf.SECRET_KEY='**';

varurl='/v2/tune/flux\n';

varaccessToken=qiniu.util.generateAccessToken(url,'');

//console.log(accessToken);

urllib.request('http://fusion.qiniuapi.com/v2/tune/flux',{

method:'POST',

headers:{

'Content-Type':'application/json',

'Authorization':accessToken,

},

data:{

'startDate':'2016-07-01',

'endDate':'2016-07-03',

'granularity':'5day',

'domains':'302-test.songfei.echohu.top'

}

},function(err,data,res){

if(err){

throwerr;//youneedtohandleerror

}

//console.log(res.statusCode);

//console.log(res.headers);

//dataisBufferinstance

console.log(data.toString())

});

标签:
随便看看
本类推荐
本类排行
热门标签

我国国家通讯社行不行啊细狗新年贺词祝福语2023年祝福语新年新年贺词新年贺词祝福语居家抗病毒小药箱除夕高速免费吗2022年除夕高速免费吗春联春联句子大全春联句子大全七字年夜饭十二道菜年夜饭十二道菜单年夜饭吃什么年夜饭吃什么菜吃年夜饭的寓意年夜饭黑芝麻菊花茶晒菊花茶腌腊肉送妈妈生日礼物汉白玉送闺蜜水钻送女人礼物爸爸生日送礼物送老公