Caricamenti
Caricare file o blocchi tramite HTTP, verificare i blocchi ricevuti, unirli in file o allegati e monitorare o pulire le attività.
Definizioni di tipo
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!
}Operazioni
POST /upload
info contiene i byte grezzi della busta cifrata per POST /upload, non testo né Base64. Invia info prima di file. In caso di successo, il corpo di testo HTTP 201 riporta il nome effettivo del file salvato. I metadati devono indicare la dimensione dichiarata in byte; quelli riutilizzati vengono rifiutati.
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
Invia i byte grezzi della busta cifrata per POST /upload_chunk in info prima di file. HTTP 201 restituisce testo nel formato index:size. Consulta uploadedChunks, poi esegui mergeChunks o mergeAppFileChunks e controlla mergeStatus. L’unione è asincrona.
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
Ricevere informazioni sul completamento o sull’errore di un’unione asincrona dei blocchi caricati.
subscription uploadMergeResult {
uploadMergeResult { fileId ok value mergedSize error }
}deleteChunks
Eliminare tutti i blocchi memorizzati per il fileId di un caricamento a blocchi. Usare dopo un caricamento annullato o non riuscito per liberare spazio su disco.
mutation deleteChunks($fileId: String!) {
deleteChunks(fileId: $fileId)
}mergeChunks
Avviare l’unione dei blocchi caricati in un file di destinazione; consultare mergeStatus per verificarne il completamento.
# 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
Leggere l’avanzamento o l’errore dell’unione di un caricamento; lo stato NONE indica che non è stata avviata alcuna unione per questo ID file.
# `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
Elencare gli indici dei blocchi già ricevuti per un caricamento a blocchi riprendibile. Serve a riprendere caricamenti interrotti.
query uploadedChunks($fileId: String!) {
uploadedChunks(fileId: $fileId) { index sizeBytes }
}