Skip to main content
Version: 3.x

Taro.getSavedFileInfo(option)

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

(option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
filePathstringYesFile path
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

SuccessCallbackResult

PropertyTypeDescription
createTimenumberThe 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
sizenumberFile size in bytes
errMsgstringCall result

Sample Code

Taro.getSavedFileInfo({
filePath: 'wxfile://somefile',
success: function (res) {
console.log(res.size)
console.log(res.createTime)
}
})

API Support

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