Artifact Workspace
Store versioned filesystem artifacts (Artifacts-style workspace on R2)
Artifacts-style versioned filesystem workspace. Cloudflare Artifacts bindings are still evolving, so this experiment uses an R2 bucket behind a typed ArtifactStore interface until a stable Artifacts binding is available.
Features
PUT /files?path=- store text contentGET /files?path=- read file contentGET /files/list?prefix=- list pathsDELETE /files?path=- delete a file
API Reference
Path rules
- Max length 256
- Allowed characters: alphanumeric,
/,_,-,. - No
..segments
PUT /files
Store text content at a path. Body is raw text.
path string (required)
Example Request
curl -X PUT "https://your-worker.workers.dev/files?path=notes/hello.txt" \
-H "Content-Type: text/plain" \
-d "hello world"Success Response
{
"path": "notes/hello.txt",
"stored": true
}GET /files
Returns the file body as text/plain, or 404 if missing.
path string (required)
Example Request
curl "https://your-worker.workers.dev/files?path=notes/hello.txt"GET /files/list
List stored paths, optionally filtered by prefix.
prefix string (optional)
Example Request
curl "https://your-worker.workers.dev/files/list?prefix=notes/"Success Response
{
"files": [{ "path": "notes/hello.txt" }],
"prefix": "notes/"
}DELETE /files
path string (required)
Example Request
curl -X DELETE "https://your-worker.workers.dev/files?path=notes/hello.txt"Success Response
{
"path": "notes/hello.txt",
"deleted": true
}Error Codes
400- Missing or invalid path/prefix (INVALID_PATH)404- File does not exist (NOT_FOUND)
Use Cases
- Learn Artifacts-style workspace patterns on Workers
- Store generated code, reports, or build outputs at the edge
- Swap R2 for a future native Artifacts binding via
ArtifactStore - Prototype multi-tenant file APIs with path prefixes
Limitations
- Uses R2 as a stand-in; not the final Artifacts product API
- Text bodies only in this demo
- Path validation rejects
..and unusual characters - No authentication or per-user isolation beyond path conventions
Deployment
Configure R2
Create the R2 bucket artifact-workspace (or update wrangler.json) and bind it as ARTIFACTS.
Test your deployment
curl -X PUT "https://your-worker.workers.dev/files?path=notes/hello.txt" \
-H "Content-Type: text/plain" \
-d "hello world"Local Development
cd apps/experiments/artifact-workspace
npm install
npm run devcurl -X PUT "http://localhost:8787/files?path=notes/hello.txt" \
-H "Content-Type: text/plain" \
-d "hello world"Configuration
wrangler.json declares:
- R2 bucket
ARTIFACTS→artifact-workspace
When a stable Artifacts binding lands, the intended shape is artifacts: [{ binding: "ARTIFACTS", name: "workspace" }]. The ArtifactStore interface isolates route code from the backend.