微信小程序转发文件到聊天API wx.shareFileMessage

追格官方小助手/ 2023年01月19日/ 小程序/ 浏览 2293

wx.shareFileMessage是微信小程序转发文件到聊天API。追格小编前面分享过《wx.shareVideoMessage微信小程序转发视频到聊天接口》,有兴趣的朋友可以看看。


示例代码:


 // 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,
  })


参数介绍:



发表评论

暂无评论,抢个沙发...

客服 工单