Uploads
Enviar arquivos ou blocos por HTTP, consultar os blocos recebidos, mesclá-los em arquivos ou anexos e acompanhar ou limpar as tarefas.
Definições de 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!
}Operações
POST /upload
info contém os bytes brutos do envelope cifrado para POST /upload, não texto nem Base64. Envie info antes de file. Em caso de sucesso, o corpo de texto HTTP 201 contém o nome efetivo do ficheiro guardado. Os metadados devem incluir o tamanho declarado em bytes; a reutilização é rejeitada.
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
Envie os bytes brutos do envelope cifrado para POST /upload_chunk em info antes de file. HTTP 201 devolve texto no formato index:size. Consulte uploadedChunks, chame mergeChunks ou mergeAppFileChunks e acompanhe mergeStatus. A junção é assíncrona.
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
Receber informações de conclusão ou falha de uma junção assíncrona de fragmentos carregados.
subscription uploadMergeResult {
uploadMergeResult { fileId ok value mergedSize error }
}deleteChunks
Eliminar todos os fragmentos guardados para o fileId de um carregamento por fragmentos. Usar após um carregamento cancelado ou falhado para libertar espaço em disco.
mutation deleteChunks($fileId: String!) {
deleteChunks(fileId: $fileId)
}mergeChunks
Iniciar a junção dos fragmentos carregados num ficheiro de destino; consultar mergeStatus para verificar a conclusão.
# 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
Consultar o progresso ou falha da junção de um carregamento; o estado NONE significa que não foi iniciada nenhuma junção para este ID de ficheiro.
# `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
Listar os índices dos fragmentos já recebidos de um carregamento por fragmentos retomável. Usado para retomar carregamentos interrompidos.
query uploadedChunks($fileId: String!) {
uploadedChunks(fileId: $fileId) { index sizeBytes }
}