Taro.getFileInfo(option)
Gets file information.
Type
(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
Taro.getFileInfo({
success: function (res) {
console.log(res.size)
console.log(res.digest)
}
})
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.getFileInfo | ✔️ | ✔️ |