업로드
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 }
}