Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API file - save files to the local


May 19, 2021 WeChat Mini Program Development Document


Table of contents


wx.saveFile(Object object)

Save the file locally. Note: SaveFile moves the temporary file, so the tempFilePath that is passed in after the call is successful will not be available

Parameters

Object object

Property Type The default Required Description
tempFilePath string Is Temporary path for files that need to be saved (local path)
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

object.success callback function

Parameters
Object res
Property Type Description
savedFilePath number Stored file path (local path)

The sample code

wx.chooseImage({
  success: function(res) {
    const tempFilePaths = res.tempFilePaths
    wx.saveFile({
      tempFilePath: tempFilePaths[0],
      success (res) {
        const savedFilePath = res.savedFilePath
      }
    })
  }
})

Attention

The size of the local file store is limited to 10M