title: Taro.getSavedFileInfo(option)

sidebar_label: getSavedFileInfo

Gets the information of local files. This API can only be used to obtain the information of files that have been saved to the local device. To obtain information of temporary files, use Taro.getFileInfo() API.

Reference

Type

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

Parameters

Option

Property Type Required Description
filePath string Yes File path
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

SuccessCallbackResult

Property Type Description
createTime number The timestamp when the file was saved, which is defined as the number of seconds that have elapsed since 1970/01/01 08:00:00 to the current time
size number File size in bytes
errMsg string Call result

Sample Code

  1. Taro.getSavedFileInfo({
  2. filePath: 'wxfile://somefile',
  3. success: function (res) {
  4. console.log(res.size)
  5. console.log(res.createTime)
  6. }
  7. })

API Support

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