第一步:获取七牛云token,这步操作很简单,请求七牛云接口即可
getUpToken: function() {
var url = "resource/getUpToken"
var header = {
token : wx.getStorageSync("token")
}
var that = this
network.requestLoading(url,"",header,"",function(data){
console.log(data)
that.setData({
up_token : data.data
})
},function(){
})
},
第二步:利用upfile API上传文件
wx.uploadFile({
formData:{token:that.data.up_token},//这里是请求头部分
url: 'url',
filePath: tempFilePaths[i],
name:"file",
success:function(data) {
var res = JSON.parse(data.data)
var image_keys = that.data.image_keys.concat(res.key)
}
})
网友评论