अपलोड
HTTP से फ़ाइलें या खंड अपलोड करें, प्राप्त खंड देखें, उन्हें फ़ाइलों या अटैचमेंट में जोड़ें और अपलोड कार्यों की स्थिति देखें या उन्हें साफ़ करें।
प्रकार परिभाषाएँ
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!
}ऑपरेशन
POST /upload
info में POST /upload के लिए एन्क्रिप्ट किए गए अनुरोध एनवेलप के मूल बाइट भेजें, टेक्स्ट या Base64 नहीं। इसे file से पहले भेजें। सफलता पर HTTP 201 के साथ सादे टेक्स्ट में वास्तव में सहेजा गया फ़ाइल नाम मिलता है।
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 के लिए एन्क्रिप्ट किए गए info के मूल बाइट file से पहले भेजें। सफलता पर HTTP 201 के साथ सादे टेक्स्ट में index:size मिलता है। uploadedChunks देखें, फिर mergeChunks या mergeAppFileChunks चलाएँ और mergeStatus से स्थिति जाँचें।
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
असमकालिक अपलोड-चंक मर्ज की पूर्णता या विफलता जानकारी लें।
subscription uploadMergeResult {
uploadMergeResult { fileId ok value mergedSize error }
}deleteChunks
चंक अपलोड fileId के सभी सहेजे चंक मिटाएँ। अपलोड रद्द या विफल होने के बाद डिस्क स्थान खाली करने के लिए उपयोग करें।
mutation deleteChunks($fileId: String!) {
deleteChunks(fileId: $fileId)
}mergeChunks
अपलोड किए चंक गंतव्य फ़ाइल में मर्ज करना शुरू करें; पूर्णता के लिए mergeStatus जाँचें।
# 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
अपलोड मर्ज की प्रगति या विफलता पढ़ें; status NONE का अर्थ है इस फ़ाइल ID के लिए मर्ज शुरू नहीं हुआ।
# `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
फिर शुरू किए जा सकने वाले चंक अपलोड में पहले से मिले चंक इंडेक्स सूचीबद्ध करें। बाधित अपलोड फिर शुरू करने में उपयोग होता है।
query uploadedChunks($fileId: String!) {
uploadedChunks(fileId: $fileId) { index sizeBytes }
}