- wx.getFileSystemManager().readFile在开发者工具有效 在微信无效?
if (this.data.imageUrls.length > 0) { this.data.imageUrls.forEach((element) => { console.log(element.url, '单图片') wx.getFileSystemManager().readFile({ filePath: element.url, success(res) { let boundary = "----abcdefg"; let boundarystart = that.stringToBuffer(`--${boundary}\r\n`); let boundaryend = that.stringToBuffer(`\r\n--${boundary}--\r\n`); let fileheader = that.stringToBuffer(`Content-Disposition: form-data; name="files";filename="123.jpg";\r\nContent-Type:image/jpeg;\r\n\r\n`); let buffers = that.concatenate(boundarystart, fileheader, res.data, boundaryend); wx.request({ data: buffers, url: 'https://www.baolegebei.com/api/lygim/upload_images', header: { 'Authorization': wx.getStorageSync(cache.token), 'content-type': `multipart/form-data; boundary=${boundary}` }, method: 'post', success(res) { if (res.data.success) { // console.log('上传成功', res.data.data[0]) let imgs = that.data.imgs; imgs.push(res.data.data[0]) that.setData({ imgs }, () => { console.log(that.data.imgs) }) } else { wx.showToast({ title: '有非法图片,禁止上传', icon: 'error', duration: 2000 }) } }, fail(error) { console.log(error); wx.showToast({ title: '上传失败', icon: 'error', duration: 2000 }) } }) }, fail(error) {} }); }) } b背景: 小程序图片需要校验才能上线,wx.getFileSystemManager().readFile读取图片信息,后台校验。 w为什么读取在开发者工具 跟 微信小程序环境不一致呢, r如下截图 [图片][图片] 两种环境下, 图片读取的url不太一样, wx.getFileSystemManager().readFile貌似好像只能读取http://tmp/yGi0tYkuQcq8400b11db0f30e52a74b8da68f34ad42c.jpg, 不能读取 wxfile://tpm_2e23rewfwefdfvdf 这种类型图片地址 望大佬指点,谢谢
2021-05-20 - 腾讯云SDK {error: "missing param Body"} ?
[图片]
2021-02-27 - 小程序使用腾讯云sdk报错问题 ?
[图片] 如上图 我i在mixins中复制了 cos-js-sdk-v5.min.js文件, 报错如下,找不到详细资料分析错误,小菜鸡请求帮助, 谢谢
2021-02-27 - 微信小程序 (发帖功能), 上传本地图片到腾讯云怎么实现?
1 我刚开始用 lin-ui组件的 imagePicker组件,但是只能实现图片本地上传,本地预览、删除等功能, 无法跟腾讯云cos对象存储交互。 cos对象代码 cos.putObject({ Bucket: '************', //存储桶用户识别 (必须有) Region: '*********', //地区识别(必须有) Key: filename, //文件名字(这里需要注意的是,如果名字是一样的,那么后面的会覆盖前面的,所以这个名字不可以重复)(必须有) StorageClass: 'STANDARD',//可以不写 Body: selectedFile, //上传文件对象 onProgress: function(progressData) { console.log(""+JSON.stringify(progressData)); } 这里红色的地方需要拿到图片对象本身。 2 微信开发平台 提供 wx.chooseImage(Object object),返回的也是没有图片本身对象object.success 回调函数参数Object res属性类型说明最低版本tempFilePathsArray.<string>图片的本地临时文件路径列表 (本地路径)tempFilesArray.<Object>图片的本地临时文件列表1.2.0 res.tempFiles 的结构 属性类型说明pathstring本地临时文件路径 (本地路径)sizenumber本地临时文件大小,单位 B 3 所以说,我有个特别大的疑问 ? 是不是我对 cos.putObject 有所误解 , 那么怎么样我才能拿到图片本身对象
2021-02-25