Tham chiếu API

Tải xuống

Kiểm tra app.capabilities để biết tính năng và app.access cùng quyền máy chủ để xác định quyền truy cập. Thay giá trị mẫu trước khi gọi.

Định nghĩa kiểu

graphql
type Subscription {
  downloadsChanged: Boolean!
}

type Mutation {
  cancelDownload(id: ID!): Boolean!
  createDownload(input: DownloadInput!): Download!
  pauseDownload(id: ID!): Boolean!
  removeDownload(id: ID!): Boolean!
  resumeDownload(id: ID!): Boolean!
  retryDownload(id: ID!): Boolean!
}

type Query {
  downloads: [Download!]!
}

input ChatDownloadInput {
	messageId: ID!
	peerId: ID!
	fileIds: [String!]!
}

type ChatDownloadSource {
	messageId: ID!
	peerId: ID!
	fileIds: [String!]!
}

type Download {
	id: ID!
	title: String!
	source: DownloadSource!
	targetDir: String!
	zipName: String
	status: DownloadStatus!
	downloadedBytes: Long!
	totalBytes: Long!
	bytesPerSecond: Long!
	totalFiles: Int!
	doneFiles: Int!
	currentFile: String!
	error: String!
	failures: [DownloadFailure!]!
}

type DownloadFailure {
	path: String!
	error: String!
}

input DownloadInput @oneOf {
	resources: ResourceDownloadInput
	chat: ChatDownloadInput
}

union DownloadSource = ResourceDownloadSource | ChatDownloadSource

enum DownloadStatus {
	PENDING
	DOWNLOADING
	PAUSED
	PACKING
	COMPLETED
	PARTIAL
	FAILED
	CANCELED
}

scalar Long

input ResourceDownloadInput {
	urls: [String!]!
	targetDir: String!
	zipName: String
}

type ResourceDownloadSource {
	urls: [String!]!
}

Thao tác

subscription

downloadsChanged

Nhận tín hiệu khi tiến độ tải xuống thay đổi.

graphql
subscription downloadsChanged {
  downloadsChanged
}
mutation

cancelDownload

Dừng tải xuống, giữ bản ghi tác vụ và các tệp đã lưu.

graphql
mutation cancelDownload($id: ID!) {
  cancelDownload(id: $id)
}
mutation

createDownload

Tạo tác vụ tải từ URL tài nguyên hoặc tệp đính kèm trò chuyện; chỉ cung cấp đúng một nguồn.

graphql
mutation createDownload($input: DownloadInput!) {
  createDownload(input: $input) { id title targetDir zipName status downloadedBytes totalBytes bytesPerSecond }
}
mutation

pauseDownload

Tạm dừng tác vụ tải được chỉ định và giữ các tệp đã hoàn tất.

graphql
mutation pauseDownload($id: ID!) {
  pauseDownload(id: $id)
}
mutation

removeDownload

Dừng tải và xóa bản ghi tác vụ; giữ các tệp đã lưu.

graphql
mutation removeDownload($id: ID!) {
  removeDownload(id: $id)
}
mutation

resumeDownload

Tiếp tục tác vụ tải hiện có đang tạm dừng.

graphql
mutation resumeDownload($id: ID!) {
  resumeDownload(id: $id)
}
mutation

retryDownload

Thử lại tác vụ tải hiện có bị lỗi, hoàn tất một phần hoặc đã hủy.

graphql
mutation retryDownload($id: ID!) {
  retryDownload(id: $id)
}
query

downloads

Liệt kê tác vụ tải với tiến độ, kết quả và lỗi hiện tại.

graphql
query downloads {
  downloads { id title targetDir zipName status downloadedBytes totalBytes bytesPerSecond }
}