Skip to content

Send the screenshots and texts of many results at once, for a project without a bucket

POST
/v1/files/direct-batch
curl --request POST \
--url https://beta-api.plune.ai/v1/files/direct-batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "items": [ { "resultId": "6f1c2b3a-0000-4000-8000-0000000000e1", "name": "batch-state-1.png", "contentType": "image/png", "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==" }, { "resultId": "6f1c2b3a-0000-4000-8000-0000000000e1", "name": "batch-console.txt", "contentType": "text/plain", "data": "aGVsbG8gZnJvbSB0aGUgcnVubmVy" } ] }'

POST /v1/results/{id}/files for many results: { "items": [{ "resultId", "name", "contentType", "data" }] }, data being the bytes in base64 (ADR 0051, #1476). At most 100 items and 6 MiB of files together (decoded; the body is a third larger) — over it the whole request is 413 batch_too_large, before anything is decoded. Each item is judged alone by the rules of the single route (a picture up to 2 MiB, a text up to 512 KiB once cleaned of credentials, UTF-8 only, 20 pictures and 10 texts a result, the run open, the result the caller’s project’s) and answered stored, exists (the result already holds a file of that name and content type with the same SHA-256 — a retried batch stores nothing twice. The server computes the SHA-256 of what it keeps, a text once cleaned; a different file of the same name, type and size is stored as another file) or refused with a code and httpStatus; a file larger than the project’s own storage budget (it differs by tariff) is over_budget. An item may carry sha256; if it is not the SHA-256 of the file as kept, the item is invalid_file. The same name and bytes twice in one request is duplicate for the second. The project’s budget is made room for once, for everything stored: its oldest files go, as for the single route, in the same transaction; evicted says how many and how many bytes. No audit entry, as for a reporter’s single upload. Counted with the other two batch routes: 6000 items a minute a person and 120 requests a minute, each per server instance (429 rate_limited with Retry-After, nothing taken). A reader of the project cannot use it.

Media type application/json
object
items
required
Array<object>
>= 1 items <= 100 items
object
resultId
required
string
name
required
string
contentType
required
string
Allowed values: image/png image/jpeg image/webp application/json text/plain
data
required

The bytes, base64. All the data of a request together: 6 MiB decoded at most.

string
sha256

Optional: must be the SHA-256 of the file as kept; the server computes it either way.

string
/^[0-9a-fA-F]{64}$/
Example
{
"items": [
{
"resultId": "6f1c2b3a-0000-4000-8000-0000000000e1",
"name": "batch-state-1.png",
"contentType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg=="
},
{
"resultId": "6f1c2b3a-0000-4000-8000-0000000000e1",
"name": "batch-console.txt",
"contentType": "text/plain",
"data": "aGVsbG8gZnJvbSB0aGUgcnVubmVy"
}
]
}

One entry per item; evicted when the budget sent files away

Media type application/json
object
items
required

One entry per item, in order.

Array<object>
object
index
required

The item’s position in the request, from 0.

integer
status
required
string
Allowed values: stored exists refused
code

For refused, why: invalid_name, invalid_content_type, invalid_file, not_found, run_closed, file_too_large, too_many_files, duplicate, no_storage, over_budget, platform_not_configured, not_connected, bucket_unreachable, file_mismatch, file_missing, upload_expired.

string
error
string
httpStatus

For refused: the status the single route answers with for the same cause.

integer
retryable

The same item may succeed if sent again unchanged.

boolean
id
string
name
string
contentType
string
size
integer
url

For upload, as in ResultFileUploadLink: a right to write that one object — do not log it.

string
method
string
Allowed values: PUT
headers
object
key
additional properties
string
expiresAt
string format: date-time
resumed

For upload: the file was announced before — same id, a new link.

boolean
evicted

What the budget sent away for the whole batch, when it sent anything.

object
count
required
integer
bytes
required
integer
Example
{
"items": [
{
"index": 0,
"status": "stored",
"id": "3f0c2a7e-1b5d-4c8e-9a61-2d7f4e8b0c13",
"name": "batch-state-1.png",
"contentType": "image/png",
"size": 70
},
{
"index": 1,
"status": "stored",
"id": "3f0c2a7e-1b5d-4c8e-9a61-2d7f4e8b0c14",
"name": "batch-console.txt",
"contentType": "text/plain",
"size": 21
}
]
}

A body that is not { items: [{ resultId, name, contentType, data }] } with 1 to 100 items

Media type application/json
object
error
required
string
Example generated
{
"error": "example"
}

No / invalid token or session

A reader of the project

Media type application/json
object
error
required
string
Example generated
{
"error": "example"
}

The files of the batch are over 6 MiB together (code: batch_too_large), or the body is over 10 MiB

Media type application/json
object
error
required
string
Example generated
{
"error": "example"
}

Rate-limited: the per-route throttle, or the per-minute request limit of the plan an API token counts by (#1442; the body names the plan, #2092). Retry-After carries the seconds until the window rolls over.

Media type application/json
object
error
required
string
Example generated
{
"error": "example"
}
Retry-After
integer

Seconds until the window rolls over