taro-微信小程序如何将url转成file文件对象
\\\\问题描述:后端需要file文件,而小程序拍照剪辑后得到的tempFilePath是临时链接,不是file文件对象。找遍了小程序的所有api都没有
本来想通过普通js写,但是小程序又不支持newImage。想看看大家有没有好的方法和案例
\#\#\# 如何将url转成file对象
\#\#\# 相关代码
Taro.canvasToTempFilePath({//调用方法,开始截取
x: x,
y: ys,
width: width,
height: areaHeight,
destWidth: destWidth,
destHeight: areaHeight,
canvasId: 'myCanvas',
success: function (res) {
Taro.showLoading({
title: '成功',
})
imgFiles.push(res.tempFilePath)
_this.setState({
imgFiles
})
Taro.hideLoading()
console.log('res.tempFilePath',i,ys,res.tempFilePath);
}
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用
wx.uploadFile
接口上传。本质就是 FormData,小程序帮你做了封装,让你传个临时路径就行了,底层怎么转换成 FormData 的跟你无关。