API 參考
檔案
透過 app.capabilities 判斷功能支援,透過 app.access 和主機權限判斷存取授權。範例使用合成值;呼叫前請替換路徑、ID、輸入和篩選條件。
型別定義
graphql
type Subscription {
fileSearchResults(root: String!, query: String!, offset: Int!, limit: Int!, sortBy: FileSortBy!): FileSearchResults!
}
type Mutation {
cacheZipEntry(path: String!): String!
copyFileToDirectory(src: String!, directory: String!, name: String!): String!
createDir(path: String!): File!
createFile(path: String!): File!
createFileTask(type: FileTaskType!, title: String!, ops: [FileTaskOpInput!]!, waitForCompletion: Boolean! = false): FileTask!
createZipArchive(paths: [String!]!, target: String!): String!
deleteFiles(paths: [String!]!): ActionResult!
deleteTrashedFile(path: String!): Boolean!
extractZipArchive(path: String!, target: String!): String!
renameFile(path: String!, name: String!): String
restoreFiles(paths: [String!]!): ActionResult!
trashFiles(paths: [String!]!): ActionResult!
writeTextFile(path: String!, content: String!, overwrite: Boolean!): File!
}
type Query {
fileCount(root: String!, query: String!): Int!
fileInfo(path: String!): FileInfo
fileTasks(query: String!, offset: Int!, limit: Int!): [FileTask!]!
files(root: String!, query: String!, offset: Int!, limit: Int!, sortBy: FileSortBy!): [File!]!
recentFiles: [File!]!
trashedFileCount(query: String!): Int!
trashedFiles(query: String!, offset: Int!, limit: Int!, sortBy: TrashedFileSortBy!): [TrashedFile!]!
}
type ActionResult {
affectedCount: Int!
}
type AudioFileInfo {
durationMs: Long!
location: Location
}
type File {
permission: String!
mediaId: ID
name: String!
path: String!
createdAt: Instant
updatedAt: Instant!
size: Long!
isDir: Boolean!
childCount: Int!
url: String!
isSystem: Boolean!
}
type FileInfo {
path: String!
updatedAt: Instant!
size: Long!
data: MediaFileInfo
}
type FileSearchResults {
items: [File!]!
offset: Long!
count: Long!
complete: Boolean!
}
enum FileSortBy {
UPDATED_AT_ASC
UPDATED_AT_DESC
SIZE_ASC
SIZE_DESC
NAME_ASC
NAME_DESC
}
type FileTask {
id: ID!
clientId: ID!
type: FileTaskType!
title: String!
status: FileTaskStatus!
error: String!
totalBytes: Long!
doneBytes: Long!
totalItems: Long!
doneItems: Long!
createdAt: Instant!
updatedAt: Instant!
completedOps: [FileTaskCompletedOp!]!
}
type FileTaskCompletedOp {
src: String!
dst: String!
}
input FileTaskOpInput {
src: String!
dst: String!
overwrite: Boolean!
}
enum FileTaskStatus {
QUEUED
RUNNING
DONE
ERROR
}
enum FileTaskType {
COPY
MOVE
}
type ImageFileInfo {
make: String!
model: String!
rotation: Int!
colorSpace: String!
apertureValue: Float!
exposureTime: String!
focalLength: String!
isoSpeed: Int!
takenAt: Instant
flash: Int!
fNumber: Float!
exposureProgram: Int!
meteringMode: Int!
whiteBalance: Int!
creator: String!
resolutionX: Int!
resolutionY: Int!
description: String!
width: Int!
height: Int!
location: Location
}
scalar Instant
type Location {
latitude: Float!
longitude: Float!
}
scalar Long
union MediaFileInfo = ImageFileInfo | AudioFileInfo | VideoFileInfo
type TrashedFile {
id: ID!
type: TrashedFileType!
originalPath: String!
disk: String!
trashRelPath: String!
deletedAt: Instant!
uid: Int!
gid: Int!
mode: Int!
sizeBytes: Long
entryCount: Int
displayName: String!
trashedPath: String!
}
enum TrashedFileSortBy {
DATE_ASC
DATE_DESC
SIZE_ASC
SIZE_DESC
NAME_ASC
NAME_DESC
}
enum TrashedFileType {
FILE
DIR
}
type VideoFileInfo {
width: Int!
height: Int!
durationMs: Long!
rotation: Int!
displayWidth: Int!
displayHeight: Int!
bitrate: Long!
frameRate: Float!
title: String!
artist: String!
album: String!
genre: String!
takenAt: Instant
writer: String!
composer: String!
location: Location
}操作
subscription
fileSearchResults
接收指定根路徑、篩選條件、頁碼和排序順序的檔案搜尋結果快照。
graphql
subscription fileSearchResults($root: String!, $query: String!, $offset: Int!, $limit: Int!, $sortBy: FileSortBy!) {
fileSearchResults(root: $root, query: $query, offset: $offset, limit: $limit, sortBy: $sortBy) { offset count complete }
}mutation
cacheZipEntry
將指定 ZIP 條目解壓到快取並回傳路徑。
graphql
mutation cacheZipEntry($path: String!) {
cacheZipEntry(path: $path)
}mutation
copyFileToDirectory
按指定目標名稱將檔案複製到目錄,在可用時回傳路徑。
graphql
mutation copyFileToDirectory($src: String!, $directory: String!, $name: String!) {
copyFileToDirectory(src: $src, directory: $directory, name: $name)
}mutation
createDir
建立目錄,並以 File 物件回傳。
graphql
mutation createDir($path: String!) {
createDir(path: $path) { permission mediaId name path createdAt updatedAt size isDir }
}mutation
createFile
在指定路徑建立空檔案,並回傳其中繼資料。
graphql
mutation createFile($path: String!) {
createFile(path: $path) { permission mediaId name path createdAt updatedAt size isDir }
}mutation
createFileTask
建立批量複製或移動工作;可選擇等待完成後再回傳工作狀態。
graphql
mutation createFileTask($type: FileTaskType!, $title: String!, $ops: [FileTaskOpInput!]!, $waitForCompletion: Boolean!) {
createFileTask(type: $type, title: $title, ops: $ops, waitForCompletion: $waitForCompletion) { id clientId type title status error totalBytes doneBytes }
}mutation
createZipArchive
將所選路徑打包為目標路徑下的 ZIP 檔案。
graphql
mutation createZipArchive($paths: [String!]!, $target: String!) {
createZipArchive(paths: $paths, target: $target)
}mutation
deleteFiles
按精確路徑刪除一個或多個檔案或目錄。
graphql
mutation deleteFiles($paths: [String!]!) {
deleteFiles(paths: $paths) { affectedCount }
}mutation
deleteTrashedFile
永久刪除檔案資源回收筒中的指定項目。
graphql
mutation deleteTrashedFile($path: String!) {
deleteTrashedFile(path: $path)
}mutation
extractZipArchive
將 ZIP 檔案解壓到目標目錄。
graphql
mutation extractZipArchive($path: String!, $target: String!) {
extractZipArchive(path: $path, target: $target)
}mutation
renameFile
重新命名檔案或目錄。
graphql
mutation renameFile($path: String!, $name: String!) {
renameFile(path: $path, name: $name)
}mutation
restoreFiles
還原指定的資源回收筒檔案路徑,並回傳受影響數量。
graphql
mutation restoreFiles($paths: [String!]!) {
restoreFiles(paths: $paths) { affectedCount }
}mutation
trashFiles
將指定檔案路徑移入資源回收筒,並回傳受影響數量。
graphql
mutation trashFiles($paths: [String!]!) {
trashFiles(paths: $paths) { affectedCount }
}mutation
writeTextFile
按指定覆蓋策略,將文字寫入給定的檔案路徑。
graphql
mutation writeTextFile($path: String!, $content: String!, $overwrite: Boolean!) {
writeTextFile(path: $path, content: $content, overwrite: $overwrite) { permission mediaId name path createdAt updatedAt size isDir }
}query
fileCount
統計指定根目錄下相符檔案搜尋的結果數,不受分頁影響。
graphql
# Total matches for the same query, ignoring paging.
query fileCount($root: String!, $query: String!) {
fileCount(root: $root, query: $query)
}query
fileInfo
讀取指定路徑的檔案屬性、支援的媒體中繼資料和標籤資訊。
graphql
query fileInfo($path: String!) {
fileInfo(path: $path) { path updatedAt size }
}query
fileTasks
分頁讀取符合查詢條件的檔案操作工作。
graphql
query fileTasks($query: String!, $offset: Int!, $limit: Int!) {
fileTasks(query: $query, offset: $offset, limit: $limit) { id clientId type title status error totalBytes doneBytes }
}query
files
分頁列出和搜尋根路徑下的檔案;query 為空時列出全部檔案。
graphql
# One page of a directory listing, filtered and sorted by the search
# DSL. `query` may carry a `parent` field to redirect the root, which
# is what the file manager's breadcrumb links send.
query files($root: String!, $query: String!, $offset: Int!, $limit: Int!, $sortBy: FileSortBy!) {
files(root: $root, query: $query, offset: $offset, limit: $limit, sortBy: $sortBy) { permission mediaId name path createdAt updatedAt size isDir }
}query
recentFiles
列出最近開啟的檔案。
graphql
# Recently-opened files. Reading them is a storage read, so this one
# gates — plain-app's `recentFiles` calls `checkEnabledAsync`.
query recentFiles {
recentFiles { permission mediaId name path createdAt updatedAt size isDir }
}query
trashedFileCount
統計檔案資源回收筒中的項目數。
graphql
query trashedFileCount($query: String!) {
trashedFileCount(query: $query)
}query
trashedFiles
分頁搜尋資源回收筒檔案,並支援排序。
graphql
query trashedFiles($query: String!, $offset: Int!, $limit: Int!, $sortBy: TrashedFileSortBy!) {
trashedFiles(query: $query, offset: $offset, limit: $limit, sortBy: $sortBy) { id type originalPath disk trashRelPath deletedAt uid gid }
}