Create & Share

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.edit for POST /api/spaces/:id/public/uploads (cohub public upload)
  • file.view for GET /api/spaces/:id/public (cohub public ls) and GET /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 presigned PUT requests.
  • Entry file ordering: When uploading a directory that contains <destination>/index.html, cohub public upload uploads all other asset files first and uploads index.html last so visitors do not load an entry page referencing missing assets, then prints the index.html URL. Directories without index.html print the uploaded file count and URL prefix: ....
  • MIME types and media metadata: Content types are inferred from file extensions (application/octet-stream fallback), with ; charset=utf-8 appended to text MIME types. For local image/* and video/* files, the CLI probes dimensions (and video duration) and stores them in object metadata (x-amz-meta-*) so HEAD requests expose media facts for previews.
  • Machine-readable output: Pass --json to 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 / --recursive to list all nested files without directory grouping. The CLI automatically follows pagination cursors (limit: 1000 per 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).publicFiles via createUpload(), list(), and url() in @neta-art/cohub.
  • Path validation: Backslashes (\) convert to /, and leading ./ and trailing / are stripped. Paths are rejected if they are empty (for upload or url), 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 with lstat(). Any symbolic link aborts the upload with Symlinks are not supported. Non-regular files (such as sockets or pipes) inside directories are skipped, and empty directories fail with Directory contains no files.
  • Overwrite protection and caching: By default, presigned upload URLs forbid overwriting existing objects (x-oss-forbid-overwrite: true on OSS or if-none-match: * on S3), failing with HTTP 409 or 412 unless --overwrite is passed. Every uploaded public file is stored with Cache-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 by ls --json have publicUrl: 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. (HTTP 409 or 412).
  • No delete subcommand: cohub public exposes only upload, ls, and url. 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 413 if 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 429 with a Retry-After header.
  • Path and source errors: Missing local sources fail with Source not found; symlinks fail with Symlinks are not supported; empty directories fail with Directory contains no files; malformed paths fail with Invalid public path.
  • url does 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_URL configured, public file routes return HTTP 503.

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 /workspace before uploading or publishing
  • Models & Generation — Generate images, video, audio, and 3D assets or supply public URLs as generation inputs
  • CLI — Full cohub CLI installation, authentication, Space targeting, and JSON output conventions