idcims
idcims
  • 发布:2020-03-04 09:58
  • 更新:2020-06-01 14:01
  • 阅读:1318

uniCloud做小程序怎么上传非图片文件?

分类:uniCloud

uniCloud做小程序怎么上传非图片文件?

2020-03-04 09:58 负责人:无 分享
已邀请:
舌尖跳舞

舌尖跳舞 - 现在不减肥,以后徒伤悲。

一个思路,前台请求云函数获取cos的token之类的,小程序根据这个token直接上传到cos,就是不知道小程序支不支持对应的插件

DCloud_heavensoft

DCloud_heavensoft

小程序的前端api,只能上传图片和视频

idcims

idcims (作者)

这就是我变了思路能实现的东西,不过还是不够方便

new Promise((resolve, reject) => {  
let that=this;  
// #ifdef MP-WEIXIN  
    wx.chooseMessageFile({  
        type: 'file',  
        count: 1,  
        success: res => {  
            var names=res.tempFiles[0].name;  
            //that.datas.name=names.substring(0,names.indexOf("."));  

            const path = res.tempFiles[0].path;  
            const options = {  
                filePath: path  
            };  
            resolve(options);  
        },  
        fail: () => {  
            reject(new Error('Fail_Cancel'));  
        }  
    });  
// #endif  

}).then(options => {  
    uni.showLoading({  
        title: '文件上传中...'  
    });  
    return uniCloud.uploadFile(options);  
})
1***@qq.com

1***@qq.com - 轩轩

请问h5上传图片的代码是什么,谢谢

该问题目前已经被锁定, 无法添加新回复