1.和APP开发一样,微信小程序使用七牛上传文件一样是需要服务器端返回Token.
2.下载七牛SDK拖入项目中,引入相应的JS文件中 const qiniuUploader = require("../../../utils/qiniuUploader");
qiniuUploader.upload(res.tempFilePath, (res) => {
var textList = that.data.textList; var params = { 'type': 'video', 'content': that.data.videoSrc } textList.push(params);
that.setData({ videoSrc: res.key, isShowVideoView: false, isShowAddVideo: true, textList: textList, }) app.hideLoading();
}, (error) => { console.log('error: ' + error); app.hideLoading(); }, { region: "SCN", domain: 'http://cdn.580dlb.cn/', //"http://p6zx74qdy.bkt.clouddn.com", key: 'uploads/tmp/article/' + timestamp + '.mp4', uptoken: that.data.qiniu_token }) }