WeChat applet API file
wx.saveFile(OBJECT)
Save the file locally.
OBJECT parameter description:
Sample code:
wx.startRecord({ success: function(res) { var tempFilePath = res.tempFilePath wx.saveFile({ tempFilePath: tempFilePath, success: function(res) { var savedFilePath = res.savedFilePath } }) } })
bug & tip
tip
: The size limit of local file storage is 10M
wx.getSavedFileList(OBJECT)
Get the local saved file list
OBJECT parameter description:
success Return parameter description:
in fileList Project description:
## Sample code: wx.getSavedFileList({
success: function(res) {
console.log(res.fileList)
}
})
OBJECT parameter description:
success Return parameter description:
##Sample code:
wx.getSavedFileInfo({
filePath: 'wxfile://somefile', //仅做示例用,非真正的文件路径
success: function(res) {
console.log(res.size)
console.log(res.createTime)
}
})
wx.removeSavedFile(OBJECT)
Delete locally stored files
OBJECT parameter description: ##Sample code:
wx.getSavedFileList({
success: function(res) {
if (res.fileList.length > 0){
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete: function(res) {
console.log(res)
}
})
}
}
})
##wx .openDocument(OBJECT)Parameters
Required | Description | ||
---|---|---|---|
is the | file path, which can be obtained through downFile | success | |
No | Callback function for successful interface call | ##fail | Function |
Callback function for failed interface call | complete | Function | |
End of interface call The callback function (executed successfully or failed) | Sample code |