item (Files)¶
Operations for reading original bytes, streaming files/previews in plugin pages, rotating or replacing files, uploading via one-use write URLs and managing thumbnails and color palettes.
item.file¶
Return an item's raw original file bytes. Over HTTP the response body is binary with the file's MIME Content-Type; curio.js resolves to a Blob.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Binary response (Blob in curio.js).
Example request
Example response Raw file bytes (200 OK, Content-Type: image/png).
Events and errors Read-only. Returns 404 not_found if the item or disk file is missing/offline. For large files in plugin pages, prefer item.fileUrl.
item.fileUrl¶
Obtain a scoped URL a plugin page can read via fetch(), <video>, <audio>, pdf.js or WebGL loaders with full HTTP Range support. For formats declared by the calling plugin, sibling files beside the primary file (such as .mtl materials, .bin buffers or textures) resolve relative to this URL.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
Returns { url: string }.
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside plugin pages; 404 not_found if missing/offline.
item.previewUrl¶
Obtain a scoped URL serving a scaled preview of any visual item (including camera RAW and PSD) at size pixels on its long edge, decoded efficiently and cached in memory.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
size |
number |
Yes | — | Target long edge in pixels (rounded up to multiples of 256, clamped 256–8192). |
Returns { url: string }.
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside plugin pages.
item.thumbnail¶
Return an item's cached thumbnail image (image/jpeg, image/png or image/webp). Over HTTP returns raw bytes; in curio.js resolves to a Blob; over MCP returns a base64 image content block (up to 4 MiB).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Binary image (Blob in curio.js, image content block in MCP).
Example request
Example response Raw image bytes (200 OK, Content-Type: image/webp).
Events and errors Read-only. Returns 404 not_found if no thumbnail exists yet.
item.rotate¶
Set non-destructive display rotation in the database without modifying the original image file on disk. To permanently rotate the file itself on disk, use item.rotateFile.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ids |
(string \| number)[] |
Yes | — | Target item IDs. |
degrees |
number |
Yes | — | Clockwise rotation angle: 0, 90, 180 or 270. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Done.
Example request
Example response
Events and errors Emits items.changed (what: "metadata").
item.rotateFile¶
Rotate the actual image file on disk clockwise in 90° quarter-turns (supports JPEG, PNG, BMP and still WebP). Rewriting the file resets any non-destructive display rotation previously set with item.rotate back to 0. Refused on read_only locations.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
turns |
number |
No | 1 |
Number of 90° clockwise turns. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Done.
Example request
Example response
Events and errors Emits items.changed (what: "file" and "thumbnail"). Returns 400 bad_request for unsupported formats, 403 not_allowed if lacking files.write, 404 not_found if the item does not exist or 422 failed on read-only locations.
item.replaceFile¶
Replace an item's file on disk with another file of the same type while preserving its UUID, folders, tags, rating, notes and custom fields. The old file goes to the system trash / Recycle Bin.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
path |
string |
One of path / data |
— | Replacement file path on disk (requires files.outside unless created in plugin run folder). |
data |
string |
One of path / data |
— | Replacement file bytes as base64 or data: URI. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Done.
Example request
Example response
Events and errors Emits items.changed (what: "file"). Refused on read_only locations (422 failed).
item.writeUrl¶
Create a single-use loopback URL that a plugin page can PUT binary file bytes to, avoiding base64 encoding overhead. The URL expires 10 minutes after it is made, so ask for it just before sending.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Target item UUID or row ID. |
mode |
string |
No | "replace" |
replace (acts like item.replaceFile) or beside (acts like item.add.beside). |
name |
string |
For beside |
— | New filename with extension when mode === "beside". |
Returns { url: string }. The subsequent PUT returns { success: true; id: string } (for replace) or Added (for beside).
Example request
Example response
Events and errors Once the PUT completes, emits items.changed (what: "file", for replace) or items.added (for beside). Returns 400 bad_request for an unknown mode or a name without an extension, 403 not_allowed outside plugin pages, 404 not_found if the item does not exist or 422 failed when replacing a file in a read-only location.
item.setThumbnail¶
Assign a custom thumbnail cover to one or more items from a local image file or base64 image bytes (updates cached aspect ratio and palette automatically).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ids |
(string \| number)[] |
Yes | — | Target item IDs. |
path |
string |
One of path / data |
— | Image file path on disk (requires files.outside unless plugin run folder). |
data |
string |
One of path / data |
— | Image bytes as base64 or data: URI. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Done.
Example request
Example response
Events and errors Emits items.changed (what: "thumbnail").
item.refreshThumbnail¶
Invalidate and queue regeneration of thumbnails for the given items (reverting custom covers back to generated thumbnails).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ids |
(string \| number)[] |
Yes | — | Target item IDs. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns Done.
Example request
Example response
Events and errors Emits items.changed (what: "thumbnail") asynchronously as thumbnails complete.
item.refreshPalette¶
Re-extract dominant color palettes from items' current thumbnails for Color filters and Spectrum view. Extraction always runs asynchronously on a background thread, so the call returns immediately with queued: true.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ids |
(string \| number)[] |
Yes | — | Target item IDs. |
library |
string |
No | Default library | Routing parameter: library ID from library.list, folder path or name. Not allowed for plugin callers. |
Returns { success: true; queued?: true } (always includes queued: true because palette extraction runs in the background).
Example request
Example response
Events and errors Emits items.changed (what: "palette") asynchronously once extraction finishes. Returns 404 not_found if any item ID does not exist.