Wechat.prototype.uploadMaterial = function(type,filepath){
var that=this;
var form={
media: fs.createReadStream(filepath)
}
return new Promise(function(resolve,reject){//
that.fetchAccesstionToken()
.then(function(data){//102 行
var url=api.upload+'access_token='+data.access_token+'&type='+type;//
request({method:'POST',url:url,formData:form,json:true})
.then(function(response){
var data=response.body;
if(data){
resolve(data)
}else{
throw new Error("Upload fails mertial")
}
})
.catch(function(err){
reject(err);
})
})
})
}