js base64图片上传七牛云

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);

}

js base64图片上传七牛云

上一篇:[JSOI2008]球形空间产生器(线性代数+高斯消元)


下一篇:MySQL内存使用的查看方式详解