抖音开放平台Logo
控制台

FileSystemManager.getSavedFileList
收藏
我的收藏

基础库 1.15.0 开始支持本方法。

获取该小程序下用户目录文件列表, 用户目录以 ttfile://user 开头。

语法

FileSystemManager.getSavedFileList(options)

参数说明

options

object 类型,属性描述如下:

属性名类型默认值必填说明最低支持版本
successFunction接口调用成功的回调函数1.15.0
failFunction接口调用失败的回调函数1.15.0
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)1.15.0

回调成功

object 类型,属性如下:

属性类型说明最低支持版本
fileListArray<FileItem>文件数组,每一项是一个 FileItem1.15.0

FileItem 的属性如下:

属性类型说明最低支持版本
filePathstring文件路径1.15.0
sizenumber本地文件大小,以字节为单位1.15.0
createTimenumber文件保存时的时间戳,从 1970/01/01 08:00:00 到当前时间的秒数1.15.0

回调失败

属性类型说明最低支持版本
errMsgstring格式为 getSavedFileList:fail + 错误信息1.15.0

代码示例

const fileSystemManager = getFileSystemManager();

fileSystemManager.getSavedFileList({
  success(res) {
    res.fileList.forEach((item) => {
      console.log(item.filePath, item.createTime, item.size);
    });
  },
  fail(res) {
    console.log("获取失败", res.errMsg);
  },
});

Bug & Tip

文档评论

登录后可参与评论