上传地址
华东 z0 服务器端上传:http(s)😕/up.qiniup.com
客户端上传: http(s)😕/upload.qiniup.com
华北 z1 服务器端上传:http(s)😕/up-z1.qiniup.com
客户端上传:http(s)😕/upload-z1.qiniup.com
华南 z2 服务器端上传:http(s)😕/up-z2.qiniup.com
客户端上传:http(s)😕/upload-z2.qiniup.com
北美 na0 服务器端上传:http(s)😕/up-na0.qiniup.com
客户端上传:http(s)😕/upload-na0.qiniup.com
新加坡 as0 服务器端上传:http(s)😕/up-as0.qiniu.com
客户端上传:http(s)😕/upload-as0.qiniu.com
wx.chooseVideo({
compressed: true,
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
maxDuration: 15,
success: async res => {
app.showLoading('上传中')
let temp_file_path = res.tempFilePath
// 返回token服务器自行实现,官方有SDK
let {
result
} = await app.api.qiniuToken()
let ret = await app.api.uploadQiniuFile({
token: result,
file_path: temp_file_path,
})
// console.log(ret.imageURL)
this.setData({
video_url: ret.imageURL,
})
wx.hideLoading()
},
complete() {
wx.hideLoading()
}
})
/**
* 上传七牛文件
*/
uploadQiniuFile(data) {
return new Promise((resolve, reject) => {
qiniu.upload(data.file_path, ret => {
resolve(ret)
}, error => {
console.log(error)
reject(error)
}, {
region: 'SCN',
uptoken: data.token,
uploadURL: 'https://upload-z2.qiniup.com/',
// 返回文件的拼接地址
domain: 'https://qiniu.sweetpapa.cn/',
shouldUseQiniuFileName: false,
})
})
},