📌 从基础库3.125.4版本开始支持
获取该小程序下的本地临时文件或本地缓存文件信息
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
filePath | string | - | 是 | 要读取的文件路径 (本地路径) |
digestAlgorithm | string | md5 | 否 | 计算文件摘要的算法 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
值 | 说明 |
---|---|
md5 | md5 算法 |
sha1 | sha1 算法 |
sha256 | sha256 算法 |
属性 | 类型 | 说明 |
---|---|---|
size | number | 文件大小,以字节为单位 |
digest | string | 按照传入的 digestAlgorithm 计算得出的的文件摘要 |
const fs = xhs.getFileSystemManager() // 异步调用 fs.getFileInfo({ filePath: `${xhs.env.USER_DATA_PATH}/hello.txt`, digestAlgorithm: 'md5', success(res) { console.log('文件大小:', res.size) console.log('文件摘要:', res.digest) }, fail(res) { console.error(res) } })