- JS API 列表
- 基础
- 网络
- 媒体
- 地图
- 文件
- 开放接口
- 数据缓存
- 地理位置
- 设备
- 画布
- 界面
- 页面导航
- 侧边栏能力
- 行业开放
- AI/AR能力
- 第三方平台
- TTML
- 转发和挂载
- 其它
- 直播能力
FileSystemManager.getFileInfo收藏我的收藏
收藏
我的收藏基础库 1.15.0 开始支持本方法,这是一个异步方法。
获取 临时目录(ttfile://temp) 或 用户目录(ttfile://user) 下的文件信息。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 无 |
注意事项 | 无 |
支持沙盒 | 否 |
相关教程 | 无 |
语法
FileSystemManager.getFileInfo(options)
参数说明
options 为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
digestAlgorithm | enum | md5 | 否 | 计算文件摘要的算法 | 1.81.0 |
filePath | string | 是 | 要读取的文件路径 | 1.15.0 | |
success | function | 否 | 接口调用成功的回调函数 | 1.15.0 | |
fail | function | 否 | 接口调用失败的回调函数 | 1.15.0 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 1.15.0 |
digestAlgorithm 的合法值
值 | 说明 | 最低支持版本 |
---|---|---|
sha1 | sha1 算法 | 1.81.0 |
md5 | md5 算法 | 1.81.0 |
回调成功
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
size | number | 文件大小,以字节为单位 | 1.15.0 |
digest | string | 按照传入的 digestAlgorithm 计算得出的的文件摘要 | 1.81.0 |
errMsg | string | "getFileInfo:ok" | 1.15.0 |
回调失败
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "getFileInfo:fail " + 错误信息 | 1.15.0 |
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|---|---|---|
20000 | getFileInfo:fail filePath is invalid | filePath 参数错误 | 1.99.0 |
21101 | getFileInfo:fail permission denied, getFileInfo %s | 文件路径不可读 | 1.99.0 |
21102 | getFileInfo:fail no such file or directory, getFileInfo %s | 文件不存在 | 1.99.0 |
21103 | getFileInfo:fail operation not permitted, getFileInfo %s | filePath 类型不是文件 | 1.99.0 |
扫码体验
请使用字节宿主APP扫码
代码示例
const fileSystemManager = tt.getFileSystemManager()
tt.chooseImage({
success(res) {
getFileInfo(res.tempFilePaths[0])
},
})
function getFileInfo(filePath) {
fileSystemManager.getFileInfo({
filePath,
digestAlgorithm: "md5",
success(res) {
console.log("文件信息:", res)
},
fail(res) {
console.log("调用失败", res.errMsg)
},
})
}
该文档是否有帮助?
点击纠错