title: Taro.getSavedFileInfo(option)

sidebar_label: getSavedFileInfo

获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 Taro.getFileInfo 接口。

支持情况:getSavedFileInfo - 图1 getSavedFileInfo - 图2 getSavedFileInfo - 图3

参考文档

类型

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

参数

参数 类型
option Option

Option

参数 类型 必填 说明
filePath string 文件路径
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (result: SuccessCallbackResult) => void 接口调用成功的回调函数

SuccessCallbackResult

参数 类型 说明
createTime number 文件保存时的时间戳,从1970/01/01 08:00:00 到该时刻的秒数
size number 文件大小,单位 B
errMsg string 调用结果

示例代码

  1. Taro.getSavedFileInfo({
  2. filePath: 'wxfile://somefile', //仅做示例用,非真正的文件路径
  3. success: function (res) {
  4. console.log(res.size)
  5. console.log(res.createTime)
  6. }
  7. })