PlainApp
API குறிப்பு

பதிவேற்றங்கள்

HTTP வழியாகக் கோப்புகள் அல்லது துண்டுகளைப் பதிவேற்றி, பெறப்பட்ட துண்டுகளைப் பார்த்து, கோப்புகளாக அல்லது இணைப்புகளாக ஒன்றிணைத்து, பதிவேற்றப் பணிகளைக் கண்காணிக்கவும் அல்லது அகற்றவும்.

வகை வரையறைகள்

graphql
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!
}

செயல்பாடுகள்

http

POST /upload

POST /upload-க்கான மறைகுறியாக்கப்பட்ட கோரிக்கை உறையின் மூல பைட்டுகளை info-வில் அனுப்பவும்; உரையாகவோ Base64 ஆகவோ அல்ல. அவற்றை file-க்கு முன் அனுப்ப வேண்டும். வெற்றிக்கு HTTP 201 மற்றும் உண்மையில் சேமிக்கப்பட்ட கோப்புப் பெயர் எளிய உரையாகக் கிடைக்கும்.

bash
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.
http

POST /upload_chunk

POST /upload_chunk-க்கான மறைகுறியாக்கப்பட்ட info-வின் மூல பைட்டுகளை file-க்கு முன் அனுப்பவும். வெற்றிக்கு HTTP 201 மற்றும் index:size எளிய உரையாகக் கிடைக்கும். uploadedChunks-ஐப் பார்த்தபின் mergeChunks அல்லது mergeAppFileChunks-ஐ அழைத்து mergeStatus மூலம் முடிவைச் சரிபார்க்கவும்.

bash
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.
subscription

uploadMergeResult

ஒத்திசைவற்ற பதிவேற்றத் துண்டு ஒன்றிணைப்பின் முடிவு அல்லது தோல்வித் தகவலைப் பெறவும்.

graphql
subscription uploadMergeResult {
  uploadMergeResult { fileId ok value mergedSize error }
}
mutation

deleteChunks

துண்டுப் பதிவேற்ற fileId-க்காகச் சேமிக்கப்பட்ட அனைத்துத் துண்டுகளையும் நீக்கவும். பதிவேற்றம் ரத்தான அல்லது தோல்வியுற்ற பிறகு வட்டு இடத்தை விடுவிக்கப் பயன்படுத்தவும்.

graphql
mutation deleteChunks($fileId: String!) {
  deleteChunks(fileId: $fileId)
}
mutation

mergeChunks

பதிவேற்றப்பட்ட துண்டுகளை இலக்குக் கோப்பாக ஒன்றிணைக்கத் தொடங்கவும்; முடிவுக்கு mergeStatus-ஐச் சரிபார்க்கவும்.

graphql
# 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 }
}
query

mergeStatus

பதிவேற்ற ஒன்றிணைப்பின் முன்னேற்றம் அல்லது தோல்வியைப் படிக்கவும்; status NONE என்றால் இந்தக் கோப்பு ID-க்கு ஒன்றிணைப்பு தொடங்கவில்லை.

graphql
# `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 }
}
query

uploadedChunks

மீண்டும் தொடரக்கூடிய துண்டுப் பதிவேற்றத்தில் ஏற்கெனவே பெறப்பட்ட துண்டு எண்களைப் பட்டியலிடவும். இடைநிறுத்தப்பட்ட பதிவேற்றத்தைத் தொடரப் பயன்படுகிறது.

graphql
query uploadedChunks($fileId: String!) {
  uploadedChunks(fileId: $fileId) { index sizeBytes }
}