Tham chiếu API

Files

Duyệt và quản lý tệp và thư mục. Hỗ trợ lưu trữ đa gắn kết (internal, SD card, USB).

Định nghĩa kiểu

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
}

Thao tác

query

mounts

Liệt kê tất cả các ổ lưu trữ khả dụng (internal, SD card, USB).

bash
query GetMounts {
  mounts {
    id name path mountPoint fsType totalBytes usedBytes freeBytes remote alias
  }
}
query

recentFiles

Liệt kê các tệp đã sửa đổi gần đây trên toàn bộ lưu trữ. Nguồn của chế độ xem "Recent" trong UI Files.

bash
query GetRecentFiles {
  recentFiles {
    name path permission createdAt updatedAt size isDir children mediaId
  }
}
query

files

Liệt kê và tìm kiếm tệp dưới một đường dẫn root với phân trang. Truyền một query trống để liệt kê tất cả.

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

Lấy stat + siêu dữ liệu media + thẻ cho một tệp duy nhất. Truyền fileName để máy chủ có thể phát hiện image/video/audio và tải width, height, duration, v.v.

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

Giải quyết một danh sách đường dẫn hệ thống tệp thành media-store ID của chúng (chuỗi rỗng khi không được lập chỉ mục).

bash
query GetFileIds($paths: [String!]!) {
  fileIds(paths: $paths)
}
query

uploadedChunks

Liệt kê các index chunk đã được nhận cho một tải lên theo chunk có thể tiếp tục. Được sử dụng để tiếp tục tải lên bị gián đoạn.

bash
query GetUploadedChunks($fileId: String!) {
  uploadedChunks(fileId: $fileId)
}
mutation

createDir

Tạo một thư mục mới và trả về nó dưới dạng một đối tượng File.

bash
mutation CreateDir($path: String!) {
  createDir(path: $path) {
    name path permission createdAt updatedAt size isDir children mediaId
  }
}
mutation

renameFile

Đổi tên một tệp hoặc thư mục.

bash
mutation RenameFile($path: String!, $name: String!) {
  renameFile(path: $path, name: $name)
}
mutation

writeTextFile

Ghi nội dung văn bản vào một tệp. Đặt overwrite=false để thêm hậu tố "(1)" khi tệp đã tồn tại.

bash
mutation WriteTextFile($path: String!, $content: String!, $overwrite: Boolean!) {
  writeTextFile(path: $path, content: $content, overwrite: $overwrite) {
    name path size updatedAt
  }
}
mutation

deleteFiles

Xóa một hoặc nhiều tệp hoặc thư mục theo đường dẫn chính xác.

bash
mutation DeleteFiles($paths: [String!]!) {
  deleteFiles(paths: $paths)
}
mutation

copyFile

Sao chép một tệp hoặc thư mục đến một đường dẫn đích. Đặt overwrite để thay thế tệp hiện có.

bash
mutation CopyFile($src: String!, $dst: String!, $overwrite: Boolean!) {
  copyFile(src: $src, dst: $dst, overwrite: $overwrite)
}
mutation

moveFile

Di chuyển một tệp hoặc thư mục đến một đường dẫn đích. Đặt overwrite để thay thế tệp hiện có.

bash
mutation MoveFile($src: String!, $dst: String!, $overwrite: Boolean!) {
  moveFile(src: $src, dst: $dst, overwrite: $overwrite)
}
mutation

addFavoriteFolder

Đánh dấu một thư mục để truy cập nhanh. Trả về danh sách cập nhật của tất cả thư mục đã đánh dấu.

bash
mutation AddFavoriteFolder($rootPath: String!, $fullPath: String!) {
  addFavoriteFolder(rootPath: $rootPath, fullPath: $fullPath) {
    rootPath fullPath alias
  }
}
mutation

removeFavoriteFolder

Xóa một thư mục đã đánh dấu. Trả về danh sách cập nhật của các thư mục còn lại.

bash
mutation RemoveFavoriteFolder($fullPath: String!) {
  removeFavoriteFolder(fullPath: $fullPath) {
    rootPath fullPath alias
  }
}
mutation

setFavoriteFolderAlias

Đặt hoặc cập nhật biệt danh hiển thị cho một thư mục đã đánh dấu. Truyền chuỗi rỗng để xóa biệt danh.

bash
mutation SetFavoriteFolderAlias($fullPath: String!, $alias: String!) {
  setFavoriteFolderAlias(fullPath: $fullPath, alias: $alias) {
    rootPath fullPath alias
  }
}
mutation

deleteChunks

Xóa tất cả chunk đã lưu cho fileId tải lên theo chunk. Sử dụng sau khi tải lên bị hủy hoặc thất bại để giải phóng dung lượng đĩa.

bash
mutation DeleteChunks($fileId: String!) {
  deleteChunks(fileId: $fileId)
}
mutation

mergeChunks

Hợp nhất các chunk đã tải lên trước đó thành tệp cuối cùng. Truyền isAppFile=true để nhập kết quả vào kho AppFile content-addressable của PlainApp (được sử dụng bởi tệp đính kèm chat).

bash
mutation MergeChunks($fileId: String!, $totalChunks: Int!, $path: String!, $replace: Boolean!, $isAppFile: Boolean!) {
  mergeChunks(fileId: $fileId, totalChunks: $totalChunks, path: $path, replace: $replace, isAppFile: $isAppFile)
}