title: Taro.removeSavedFile(option)

sidebar_label: removeSavedFile

Deletes local cache files.

Reference

Type

  1. (option: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
filePath string Yes Path to the file to be deleted
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

RemoveSavedFileFailCallbackResult

Property Type Description
errMsg string Error message

valid value:
- ‘fail file not exist’;

Sample Code

  1. Taro.getSavedFileList({
  2. success: function (res) {
  3. if (res.fileList.length > 0){
  4. Taro.removeSavedFile({
  5. filePath: res.fileList[0].filePath,
  6. complete: function (res) {
  7. console.log(res)
  8. }
  9. })
  10. }
  11. }
  12. })

API Support

API WeChat Mini-Program H5 React Native
Taro.removeSavedFile ✔️ ✔️