# wx.shareFileMessage(Object object)
Start from base library version 2.16.1. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Not supported
Forward file to chat
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
filePath | string | yes | The file address to share must be local or temporary | |
fileName | string | no | Customize the filename, if left blank use the filePath file name | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
# sample code
// callback Writing method
wx.downloadFile({
url: URL, // Download url
success (res) {
// Repost after download
wx.shareFileMessage({
filePath: res.tempFilePath,
success() {},
fail: console.error,
})
},
fail: console.error,
})
// async await Writing method
const { tempFilePath } = await wx.downloadFile({
url: URL, // Download url
})
// Repost after download
await wx.shareFileMessage({
filePath: res.tempFilePath,
})