title: Taro.getFileInfo(option)

sidebar_label: getFileInfo

Gets file information.

Reference

Type

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

Parameters

Option

Property Type Required Description
filePath string Yes The path to the local file
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

FailCallbackResult

Property Type Description
errMsg string Error message

valid value:
- ‘fail file not exist’;

SuccessCallbackResult

Property Type Description
size number File size in bytes
errMsg string Call result

Sample Code

  1. Taro.getFileInfo({
  2. success: function (res) {
  3. console.log(res.size)
  4. console.log(res.digest)
  5. }
  6. })

API Support

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