1.
imgUri:base64文件流
function putb64(imgUri){
/*picUrl用来存储返回来的url*/
var picUrl;
var pic = imgUri.substring(31);//截取掉逗号之前的内容
var url = "https://up.qiniup.com/putb64/-1";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function(){
if (xhr.readyState==4){
var keyText=xhr.responseText;
var strToObj = JSON.parse(keyText);json字符串转json对象
picUrl="http://ysv11.zjhaly.top/"+strToObj.key;
callNative.download(picUrl);
}
}
$.ajax({
async: false,
type : "POST",
url : "{:URL(‘News/getToken‘)}",
dataType : ‘json‘,
success : function(data) {
token=data;
}
});
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.setRequestHeader("Authorization", "UpToken "+token);
xhr.send(pic);
}