API 参考
Files
浏览并管理文件和目录。支持多挂载存储(内部存储、SD 卡、USB)。
类型定义
bash
type File {
name: String!
path: String!
permission: String! # "rw" | "r"
createdAt: String # ISO 8601, null on some filesystems
updatedAt: String! # ISO 8601
size: Long! # 0 for directories
isDir: Boolean!
children: Int! # 0 for files; child count for directories
mediaId: String! # media store ID, empty when unavailable
}
type StorageMount {
id: String!
name: String!
path: String!
mountPoint: String!
fsType: String!
totalBytes: Long!
usedBytes: Long!
freeBytes: Long!
remote: Boolean!
alias: String!
}
type FileInfo {
path: String!
updatedAt: String!
size: Long!
tags: [Tag!]!
data: MediaFileInfo # image/video/audio metadata, null for other types
}
type MediaFileInfo {
# Union-like structure; fields vary by media type (image / video / audio)
width: Int
height: Int
duration: Int # milliseconds (video / audio)
artist: String
album: String
title: String
}
type FavoriteFolder {
rootPath: String!
fullPath: String!
alias: String # optional display alias, empty when not set
}操作
query
mounts
列出所有可用的存储卷(内部存储、SD 卡、USB)。
bash
query GetMounts {
mounts {
id name path mountPoint fsType totalBytes usedBytes freeBytes remote alias
}
}query
recentFiles
列出所有存储中最近修改的文件。Files UI 中 "最近" 视图的数据源。
bash
query GetRecentFiles {
recentFiles {
name path permission createdAt updatedAt size isDir children mediaId
}
}query
files
在根路径下列出并搜索文件,支持分页。传入空查询可列出全部。
bash
query GetFiles($root: String!, $offset: Int!, $limit: Int!, $query: String!, $sortBy: FileSortBy!) {
files(root: $root, offset: $offset, limit: $limit, query: $query, sortBy: $sortBy) {
name path permission createdAt updatedAt size isDir children mediaId
}
}query
fileInfo
获取单个文件的 stat + 媒体元数据 + 标签。传入 fileName 以便服务器检测图片/视频/音频并加载宽度、高度、时长等。
bash
query GetFileInfo($id: ID!, $path: String!, $fileName: String!) {
fileInfo(id: $id, path: $path, fileName: $fileName) {
path updatedAt size
tags { id name }
data { width height duration artist album title }
}
}query
fileIds
将文件系统路径列表解析为其媒体存储 ID(未索引时为空字符串)。
bash
query GetFileIds($paths: [String!]!) {
fileIds(paths: $paths)
}query
uploadedChunks
列出可恢复分片上传中已接收的分片索引。用于恢复中断的上传。
bash
query GetUploadedChunks($fileId: String!) {
uploadedChunks(fileId: $fileId)
}mutation
createDir
创建新目录并将其作为 File 对象返回。
bash
mutation CreateDir($path: String!) {
createDir(path: $path) {
name path permission createdAt updatedAt size isDir children mediaId
}
}mutation
renameFile
重命名文件或目录。
bash
mutation RenameFile($path: String!, $name: String!) {
renameFile(path: $path, name: $name)
}mutation
writeTextFile
将文本内容写入文件。设置 overwrite=false 可在文件已存在时附加 "(1)" 后缀。
bash
mutation WriteTextFile($path: String!, $content: String!, $overwrite: Boolean!) {
writeTextFile(path: $path, content: $content, overwrite: $overwrite) {
name path size updatedAt
}
}mutation
deleteFiles
按精确路径删除一个或多个文件或目录。
bash
mutation DeleteFiles($paths: [String!]!) {
deleteFiles(paths: $paths)
}mutation
copyFile
将文件或目录复制到目标路径。设置 overwrite 可替换已存在的文件。
bash
mutation CopyFile($src: String!, $dst: String!, $overwrite: Boolean!) {
copyFile(src: $src, dst: $dst, overwrite: $overwrite)
}mutation
moveFile
将文件或目录移动到目标路径。设置 overwrite 可替换已存在的文件。
bash
mutation MoveFile($src: String!, $dst: String!, $overwrite: Boolean!) {
moveFile(src: $src, dst: $dst, overwrite: $overwrite)
}mutation
addFavoriteFolder
收藏文件夹以便快速访问。返回所有已收藏文件夹的更新列表。
bash
mutation AddFavoriteFolder($rootPath: String!, $fullPath: String!) {
addFavoriteFolder(rootPath: $rootPath, fullPath: $fullPath) {
rootPath fullPath alias
}
}mutation
removeFavoriteFolder
移除已收藏的文件夹。返回剩余文件夹的更新列表。
bash
mutation RemoveFavoriteFolder($fullPath: String!) {
removeFavoriteFolder(fullPath: $fullPath) {
rootPath fullPath alias
}
}mutation
setFavoriteFolderAlias
设置或更新已收藏文件夹显示的别名。传入空字符串可清除别名。
bash
mutation SetFavoriteFolderAlias($fullPath: String!, $alias: String!) {
setFavoriteFolderAlias(fullPath: $fullPath, alias: $alias) {
rootPath fullPath alias
}
}mutation
deleteChunks
删除分片上传 fileId 的所有已存储分片。在取消或失败的上传后使用以释放磁盘空间。
bash
mutation DeleteChunks($fileId: String!) {
deleteChunks(fileId: $fileId)
}mutation
mergeChunks
将先前上传的分片合并为最终文件。传入 isAppFile=true 可将结果导入 PlainApp 的内容寻址 AppFile 存储(由聊天附件使用)。
bash
mutation MergeChunks($fileId: String!, $totalChunks: Int!, $path: String!, $replace: Boolean!, $isAppFile: Boolean!) {
mergeChunks(fileId: $fileId, totalChunks: $totalChunks, path: $path, replace: $replace, isAppFile: $isAppFile)
}