- JS API 列表
- 基础
- 网络
- 媒体
- 地图
- 文件
- 开放接口
- 数据缓存
- 地理位置
- 设备
- 画布
- 界面
- 页面导航
- 侧边栏能力
- 行业开放
- AI/AR能力
- 第三方平台
- TTML
- 转发和挂载
- 其它
- 直播能力
tt.removeSavedFile收藏我的收藏
收藏
我的收藏基础库 1.15.0 开始支持本方法,这是一个异步方法。
删除该小程序下用户目录内的文件,用户目录以 ttfile://user 开头。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 无 |
注意事项 | 无 |
支持沙盒 | 否 |
相关教程 | 无 |
语法
tt.removeSavedFile(options)
参数说明
options 为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
filePath | string | 是 | 要删除的文件路径 | 1.15.0 | |
success | function | 否 | 接口调用成功的回调函数 | 1.15.0 | |
fail | function | 否 | 接口调用失败的回调函数 | 1.15.0 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 1.15.0 |
回调成功
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | removeSavedFile:ok | 1.15.0 |
回调失败
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | 格式为 removeSavedFile:fail + 错误信息 | 1.15.0 |
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|---|---|---|
20000 | removeSavedFile:fail filePath is invalid | filePath 参数错误 | 1.15.0 |
21101 | removeSavedFile:fail permission denied, removeSavedFile %s | 路径不可写 | 1.99.0 |
21102 | removeSavedFile:fail no such file or directory, removeSavedFile %s | 文件不存在 | 1.99.0 |
21104 | removeSavedFile:fail operation not permitted, removeSavedFile %s | filePath 类型不是文件 | 1.99.0 |
扫码体验
请使用字节宿主APP扫码
代码示例
tt.getSavedFileList({
success(res) {
console.log("当前用户目录下的文件:", res.fileList)
removeSavedFile(res.fileList)
},
})
function removeSavedFile(fileList) {
fileList.forEach((filePath) => {
tt.removeSavedFile({
filePath,
success(res) {
console.log(`${filePath} 删除成功`)
},
fail(res) {
console.error(`${filePath} 删除失败`, res.errMsg)
},
})
})
}
该文档是否有帮助?
点击纠错