Files
An HTML artifact can carry files: images, JSON or CSV data, stylesheets, scripts, fonts, audio, video and PDFs, served next to the page. The page uses them by relative path, the way a small website would: <img src="img/logo.png">, <link rel="stylesheet" href="css/site.css">, fetch('data/desks.json').
Files belong to the artifact’s versions. Every change to them makes a new version, and restoring an older version from history brings back its files too.
Only HTML artifacts carry files. Markdown artifacts don’t.
Where to find them
Section titled “Where to find them”Open an HTML artifact and choose Files in its More actions (⋯) menu. Everyone who can open the artifact can browse its files by folder. Editors and Owners can also upload files (drop them onto the list), make folders, and move and delete files.
Using files in a page
Section titled “Using files in a page”Refer to a file by its path relative to the page, with no leading slash:
<link rel="stylesheet" href="css/site.css"><img src="img/team/sam.jpg" alt="Sam"><script src="js/board.js"></script><video src="media/demo.mp4" controls></video><script> fetch('data/desks.json').then((r) => r.json()).then(showDesks);</script>Paths in CSS work the same way, relative to the stylesheet: url(../fonts/inter.woff2) from css/site.css.
A good layout keeps data in data/, images in img/, styles in css/, scripts in js/ and fonts in fonts/. ShareCube doesn’t require it, but agents and people find things faster.
Files are for what the page ships with. What people do on the page, like ticked boxes, votes or cards on a board, belongs in persistent state. A page can’t change its own files.
Adding files with an agent
Section titled “Adding files with an agent”Ask for what you want, for example “add our logo and the photos from this folder” or “move the desk list into a JSON file”. These are the MCP tools agents use:
| To | Use |
|---|---|
| Publish a page and its files together | create_artifact or update_artifact with files |
| Change the page’s HTML and some files in one step | edit_artifact with files |
| Add or replace one file | write_artifact_file |
| Change part of a text file | edit_artifact_file |
| Rename or move a file | move_artifact_file |
| Remove a file | delete_artifact_file, or null for its path in files |
| Read a file | get_artifact_file (text comes back inline, anything else as a link) |
| Upload large files, many files, or binary from code | request_artifact_upload with files, then commit_artifact_upload |
files maps each path to where its content comes from:
{ "data/desks.json": { "content": "[{\"id\": 1, \"name\": \"Window\"}]" }, "img/logo.png": { "url": "https://example.com/logo.png" }, "img/chart.png": { "content_base64": "iVBORw0KGgo..." }, "css/site.css": { "from": { "artifact": "01a1b6a6-76ed-7000-9383-fa9b7ae8401b", "path": "css/site.css" } }, "old/notes.txt": null}| Source | For |
|---|---|
content | Text: HTML, CSS, JS, JSON, CSV, SVG, Markdown |
url | A file on the web. ShareCube fetches it, up to 10 MB. |
content_base64 | Small binary files the agent’s own code produced |
from | A copy of a file from another artifact you can open |
null | Remove the file |
Paths left out of files are kept as they are.
Tips for agents
Section titled “Tips for agents”- Never type out base64 for an image. Give its
url, or upload it from code withrequest_artifact_upload. Base64 written out by a model is slow, costly and easily corrupted. - Keep each call under 4 MB, base64 included, which makes a binary file about 3 MB. Send more over several calls, or use an upload session.
- Use relative paths with no leading slash.
/img/logo.pngand full URLs to the file don’t work. - Publish the page and its files in one call where you can, so nobody opens a page whose images aren’t there yet.
- Read before you write. Pass
base_version_idfromget_artifactwhen you update. If someone else saved in between, you get a conflict instead of undoing their change: read the artifact again and redo yours.
Large and many files
Section titled “Large and many files”For big files, many files, or bytes your own code produced, use an upload session:
- Call
request_artifact_uploadwithfiles, a list of{ "path", "size", "sha256" }(size in bytes, sha256 in lowercase hex). Addpageas{ "size", "sha256" }to change the HTML too, andremovesfor paths to delete. Passidandbase_version_idto update an artifact, orproject_idanddisplay_nameto create one. You get back asession_idand where to upload each file. Files the artifact already has aren’t asked for again. PUTeach file’s raw bytes to its URL with exactly the headers given. A large file comes withparts:PUTeachpart_sizeslice to its part’s URL, in order.- Within the hour, call
commit_artifact_uploadwith thesession_id. It answerscommitting; call it again until it sayscommitted(with the new version) orfailed(with the reason).
A file that hasn’t arrived is named in the error. Upload it and commit again. One session takes at most 500 new files.
Paths and types
Section titled “Paths and types”- Paths are relative, use
/between folders, have at most 10 parts and 255 bytes in all, and are case-sensitive. - Each part uses only letters, digits and
. _ - ~, and can’t be.or... No spaces:img/team photo.jpgis refused,img/team-photo.jpgworks. doc,printand anything under_sc/are reserved.
The extension decides the type, and the content has to match it: a .png has to really be a PNG. JPEG, PNG, WebP and GIF images are stored without their metadata (EXIF, GPS location, XMP and comments).
| Kind | Extensions |
|---|---|
| Pages and code | html, htm, css, js, mjs, json, txt, md, csv, xml, wasm |
| Images | png, jpg, jpeg, gif, webp, avif, ico, svg |
| Fonts | woff, woff2, ttf, otf |
| Audio and video | mp3, m4a, wav, ogg, mp4, webm |
| Documents and 3D | pdf, glb, gltf |
Anything else is refused.
Limits
Section titled “Limits”| Free | Pro | Team | |
|---|---|---|---|
| One file | 10 MB | 500 MB | 500 MB |
| All of one version’s files | 25 MB | 2 GB | 2 GB |
| Files in one version | 100 | 1,000 | 1,000 |
The page itself stays at most 4 MB. Files count toward your organization’s storage, older versions’ files included, until those versions expire or the artifact is deleted.
When someone saves at the same time
Section titled “When someone saves at the same time”Two saves of the same artifact can’t both win. If an agent or person saves while a file is being added, the second save is refused with a conflict rather than publishing a version without that file. Read the artifact again and save once more. Agents do this on their own.
What files can’t do
Section titled “What files can’t do”- A page can’t upload or change files while people use it. Use persistent state for what people add.
- Files are served only to people who can open the artifact, and only alongside it.
- See what runs in an HTML page for what the page’s sandbox allows.