Send the screenshots and texts of many results at once, for a project without a bucket
const url = 'https://beta-api.plune.ai/v1/files/direct-batch';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"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"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
object
The bytes, base64. All the data of a request together: 6 MiB decoded at most.
Optional: must be the SHA-256 of the file as kept; the server computes it either way.
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" } ]}Responses
Section titled “ Responses ”One entry per item; evicted when the budget sent files away
object
One entry per item, in order.
object
The item’s position in the request, from 0.
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.
For refused: the status the single route answers with for the same cause.
The same item may succeed if sent again unchanged.
For upload, as in ResultFileUploadLink: a right to write that one object — do not log it.
object
For upload: the file was announced before — same id, a new link.
What the budget sent away for the whole batch, when it sent anything.
object
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
object
Example generated
{ "error": "example"}No / invalid token or session
A reader of the project
object
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
object
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.
object
Example generated
{ "error": "example"}Headers
Section titled “Headers ”Seconds until the window rolls over