Public files
Upload static files and directories to direct public CDN URLs with cohub public, list hosted paths, inspect limits and caching, and choose between public files and Apps.
This page explains how to upload static files or directories to direct public CDN URLs with cohub public, list hosted paths and resolve URLs, understand path rules, caching, and upload limits, and decide when to publish a versioned App instead.
Public files vs published Apps
cohub public stages files onto object storage behind the public files CDN under a Space-scoped prefix:
https://public.cohub.live/p/<spaceId>/<path>
Use public files when you need raw, unauthenticated static asset URLs (downloads, rendered media, sprites, JSON feeds, or standalone static bundles). Use Apps when you need a hosted, versioned application entry point.
| Capability | Public files (cohub public) |
Published Apps (cohub apps) |
|---|---|---|
| URL format | <CDN_ORIGIN>/p/<spaceId>/<path> (no username or Space slug required) |
/:username/:spaceSlug/w/:appSlug |
| Access control | Always publicly readable by URL | public (Anyone with the link) or space (Use space access) |
| Versioning & rollback | None—paths are overwritten in place with --overwrite |
Immutable versioned releases with history and status toggle |
App runtime (context(), grants, commerce) |
Not available | Supported inside published Cohub-hosted Apps |
| Custom domain & view stats | Not available | Supported (custom domains for file/directory Apps) |
| Live Sandbox ports & Boards | Static files only | Supports file, .board, directory, and Sandbox port (3000/5173) |
Target Space and permissions
cohub public resolves its target Space in standard CLI order: -s <space> (or --space <space>), then COHUB_SPACE_ID, then the current directory's Local Runtime binding. When none is set, it falls back to your Home Space.
API permissions required on the target Space:
file.editforPOST /api/spaces/:id/public/uploads(cohub public upload)file.viewforGET /api/spaces/:id/public(cohub public ls) andGET /api/spaces/:id/public/url(cohub public url)
Upload, list, and resolve URLs
cohub public provides three subcommands: upload, ls, and url.
# Upload a single file (destination defaults to the filename)
cohub -s <space-id> public upload ./report.pdf
# Upload a file to an explicit path or folder prefix (trailing "/" appends basename)
cohub -s <space-id> public upload ./poster.png assets/2026/poster-v1.png
cohub -s <space-id> public upload ./poster.png assets/2026/
# Upload a static directory (uploads index.html last when present)
cohub -s <space-id> public upload ./dist demo
# Replace existing files at the same destination
cohub -s <space-id> public upload ./dist demo --overwrite
# List public files at the Space root or under a prefix
cohub -s <space-id> public ls
cohub -s <space-id> public ls demo --recursive --json
# Print the direct public URL for a path
cohub -s <space-id> public url demo/index.html
Upload behavior (cohub public upload <source> [destination])
- Destination resolution:
- Single file: omitting
[destination]uses the file's basename; a[destination]ending in/appends the basename; any other value is used verbatim as the public path. The command prints the direct public URL. - Directory: omitting
[destination]uses the directory's basename. All regular files beneath it upload under<destination>/using up to 4 concurrent presignedPUTrequests.
- Single file: omitting
- Entry file ordering: When uploading a directory that contains
<destination>/index.html,cohub public uploaduploads all other asset files first and uploadsindex.htmllast so visitors do not load an entry page referencing missing assets, then prints theindex.htmlURL. Directories withoutindex.htmlprint the uploaded file count andURL prefix: .... - MIME types and media metadata: Content types are inferred from file extensions (
application/octet-streamfallback), with; charset=utf-8appended to text MIME types. For localimage/*andvideo/*files, the CLI probes dimensions (and video duration) and stores them in object metadata (x-amz-meta-*) soHEADrequests expose media facts for previews. - Machine-readable output: Pass
--jsonto print{ destination, urlPrefix, files: [{ path, size, mimeType }] }.
Listing and URL lookup (cohub public ls, cohub public url)
cohub public ls [path]: Lists direct children under[path](or the Space's public root when omitted), sorted with directories first (suffixed with/), then files alphabetically. Pass-r/--recursiveto list all nested files without directory grouping. The CLI automatically follows pagination cursors (limit: 1000per page; the HTTP API defaults to 200 and caps at 1,000).cohub public url <path>: Normalizes<path>and prints its full public URL. It formats the URL from the path without checking whether an object has been uploaded there.- SDK: Programmatic access is available on
client.space(spaceId).publicFilesviacreateUpload(),list(), andurl()in@neta-art/cohub.
Path validation, symlinks, caching, and directory links
- Path validation: Backslashes (
\) convert to/, and leading./and trailing/are stripped. Paths are rejected if they are empty (foruploadorurl), start with/, contain control characters (0x00–0x1f,0x7f–0x9f), contain empty segments (//),., or.., include any segment over 255 characters, or exceed 4,096 characters total. - Symlinks rejected: Both the upload
<source>and every entry walked inside a directory are checked withlstat(). Any symbolic link aborts the upload withSymlinks are not supported. Non-regular files (such as sockets or pipes) inside directories are skipped, and empty directories fail withDirectory contains no files. - Overwrite protection and caching: By default, presigned upload URLs forbid overwriting existing objects (
x-oss-forbid-overwrite: trueon OSS orif-none-match: *on S3), failing with HTTP409or412unless--overwriteis passed. Every uploaded public file is stored withCache-Control: public, max-age=300, stale-while-revalidate=3600(5-minute freshness plus up to 1 hour stale-while-revalidate). Because browsers and upstream CDN caches may continue serving the previous version after--overwrite, upload to a new versioned filename or path whenever you need an immediate update. - Link to concrete files, not bare directories: Public files map to individual object keys (
p/<spaceId>/<path>), and directory entries returned byls --jsonhavepublicUrl: null. When sharing a static directory, link directly to a concrete file such as.../demo/index.html.
Boundaries & common errors
- Existing file without
--overwrite: Uploading to an existing path fails with<path> already exists. Use --overwrite.(HTTP409or412). - No delete subcommand:
cohub publicexposes onlyupload,ls, andurl. Uploaded URLs remain publicly readable by anyone who has the link; avoid uploading secrets or private files. - File and batch caps:
- Maximum single file size: 2 GiB
- Maximum combined batch size: 2 GiB
- Maximum files per upload batch: 2,000 files
- Maximum upload-plan JSON request body: 6 MiB (HTTP
413if exceeded) - Presigned upload URL lifetime: 1 hour
- Per-user upload rate limit (HTTP 429): Durable uploads across Space files, public files, chat/App attachments, and gateway attachments share a fixed-window quota of 5,000 files and 10 GiB per hour per user. Exceeding it returns HTTP
429with aRetry-Afterheader. - Path and source errors: Missing local sources fail with
Source not found; symlinks fail withSymlinks are not supported; empty directories fail withDirectory contains no files; malformed paths fail withInvalid public path. urldoes not verify existence:cohub public url <path>succeeds for any valid path string even if no file exists at that key yet.- Unconfigured storage (HTTP 503): In self-hosted deployments without object storage or
PUBLIC_ASSET_CDN_BASE_URLconfigured, public file routes return HTTP503.
Next steps
- Apps — Publish versioned HTML, Board, static directory, or Sandbox port Apps with visibility controls and custom domains
- Files & Sandbox — Manage private workspace files inside
/workspacebefore uploading or publishing - Models & Generation — Generate images, video, audio, and 3D assets or supply public URLs as generation inputs
- CLI — Full
cohubCLI installation, authentication, Space targeting, and JSON output conventions