微信小程序
wx.shareFileMessage
# wx.shareFileMessage(Object object)
基础库 2.16.1 开始支持,低版本需做兼容处理。
以 Promise 风格 调用:支持
小程序插件:不支持
# 功能描述
转发文件到聊天
# 参数
# Object object
# 示例代码
// callback 写法
wx.downloadFile({
url: URL, // 下载url
success (res) {
// 下载完成后转发
wx.shareFileMessage({
filePath: res.tempFilePath,
success() {},
fail: console.error,
})
},
fail: console.error,
})
// async await 写法
const { tempFilePath } = await wx.downloadFile({
url: URL, // 下载url
})
// 下载完成后转发
await wx.shareFileMessage({
filePath: res.tempFilePath,
})