Skip to main content
Version: 3.x

Taro.getFileInfo(option)

Gets file information.

Reference

Type

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

Parameters

Option

PropertyTypeRequiredDescription
filePathstringYesThe path to the local file
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

FailCallbackResult

PropertyTypeDescription
errMsgstringError message

valid value:
- 'fail file not exist';

SuccessCallbackResult

PropertyTypeDescription
sizenumberFile size in bytes
errMsgstringCall result

Sample Code

Taro.getFileInfo({
success: function (res) {
console.log(res.size)
console.log(res.digest)
}
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getFileInfo✔️✔️