Yüklemeler
HTTP üzerinden dosya veya parça yükleyin, alınan parçaları sorgulayın, dosya veya ek olarak birleştirin ve yükleme görevlerini izleyin veya temizleyin.
Tip Tanımları
type Subscription {
uploadMergeResult: UploadMergeResult!
}
type Mutation {
deleteChunks(fileId: String!): Boolean!
mergeChunks(fileId: String!, totalChunks: Int!, path: String!, replace: Boolean!, totalSize: Long!): MergeTask!
}
type Query {
mergeStatus(fileId: String!): MergeTask!
uploadedChunks(fileId: String!): [UploadedChunk!]!
}
scalar Long
type MergeTask {
status: MergeTaskStatus!
value: String
mergedSize: Long
error: String
}
enum MergeTaskStatus {
NONE
STARTED
MERGING
DONE
FAILED
}
type UploadMergeResult {
fileId: ID!
ok: Boolean!
value: String
mergedSize: Long
error: String
}
type UploadedChunk {
index: Int!
sizeBytes: Long!
}İşlemler
POST /upload
info, POST /upload için şifreli istek zarfının ham baytlarıdır; metin veya Base64 değildir ve file alanından önce gönderilmelidir. Başarı durumunda HTTP 201 ve düz metin olarak gerçekten kaydedilen dosya adı döner.
curl 'https://<device-host>:<https-port>/upload' \
-H 'c-id: <client-id>' \
-F 'info=<./encrypted-info.bin' -F 'file=@./example.txt'
# Send info before file. Metadata JSON: { dir, replace, isAppFile, size }
# info contains raw encrypted request-envelope bytes for POST /upload.
# A Bearer header alone does not authenticate multipart uploads.POST /upload_chunk
POST /upload_chunk için şifreli info alanını ham bayt olarak file alanından önce gönderin. Başarı durumunda HTTP 201 ve düz metin olarak index:size döner. uploadedChunks değerini inceleyin, ardından mergeChunks veya mergeAppFileChunks çağırın ve mergeStatus ile sonucu izleyin.
curl 'https://<device-host>:<https-port>/upload_chunk' \
-H 'c-id: <client-id>' \
-F 'info=<./encrypted-info.bin' -F 'file=@./chunk.bin'
# Metadata JSON: { fileId, index, size }; bind encryption to POST /upload_chunk.
# Inspect uploadedChunks; call mergeChunks with totalSize for normal files,
# or mergeAppFileChunks for app attachments. Poll mergeStatus for completion.uploadMergeResult
Eşzamansız yükleme parçası birleştirmesinin tamamlanma veya hata bilgilerini alır.
subscription uploadMergeResult {
uploadMergeResult { fileId ok value mergedSize error }
}deleteChunks
Parçalı yüklemenin fileId değeri için kayıtlı tüm parçaları siler. Disk alanı açmak için iptal veya başarısız yükleme sonrası kullanın.
mutation deleteChunks($fileId: String!) {
deleteChunks(fileId: $fileId)
}mergeChunks
Yüklenen parçaları hedef dosyaya birleştirmeye başlar; tamamlanma için mergeStatus inceleyin.
# Starts the merge and returns immediately; completion arrives over the
# websocket, and `mergeStatus` is the polling fallback for a lost event.
mutation mergeChunks($fileId: String!, $totalChunks: Int!, $path: String!, $replace: Boolean!, $totalSize: Long!) {
mergeChunks(fileId: $fileId, totalChunks: $totalChunks, path: $path, replace: $replace, totalSize: $totalSize) { status value mergedSize error }
}mergeStatus
Yükleme birleştirme ilerlemesini veya hatasını okur; NONE bu dosya kimliği için birleştirmenin başlamadığını belirtir.
# `NONE` when no merge was ever started for this id, which is what a
# client sees before it calls `mergeChunks`.
query mergeStatus($fileId: String!) {
mergeStatus(fileId: $fileId) { status value mergedSize error }
}uploadedChunks
Sürdürülebilir parçalı yükleme için alınmış parça indekslerini listeler. Kesilen yüklemeleri sürdürmek için kullanılır.
query uploadedChunks($fileId: String!) {
uploadedChunks(fileId: $fileId) { index sizeBytes }
}