File Storage
Docs menu

Guides

Integration guide

Step-by-step CDN loader install, mount() options, storage backends, CSP/iframe notes, and troubleshooting for production embeds.

Architecture: where secrets live

The SDK is a browser UI delivered through a public loader + encrypted iframe. Pass an apiKey from the dashboard, register your site under Websites, and keep AWS / blob secrets on a server you control (or use Managed hosting).

LayerRoleCredentials
Browser / SDKUI, fetch to your APIsNever embed AWS keys. Public URLs + optional Bearer headers only.
Vite demo clientLocal demoOnly DEMO_* (see Vite envPrefix).
S3 proxy / your APIS3 ListObjects, PutObject, …AWS_ACCESS_KEY_ID, secret, IAM role, etc.

Integration checklist

  1. Create a plan + API key in the dashboard.
  2. Register every page host under Websites (include localhost for local work).
  3. Add <script src="https://cdn.filestorage.io/loader.min.js"></script> once per page.
  4. Provide a storage backend: your S3 proxy, HTTP API, or Managed storage.
  5. Call FileStorageSDK.mount({ el, apiKey, s3 | http }) on a container with an explicit height.
  6. Allow CDN + API in CSP (below) and call unmount() on teardown.

Install (CDN loader — production)

Production embeds load only loader.min.js. There is no public file-storage.min.js or file-storage.css to include.

index.html
<div id="fm" style="height: 70vh"></div>
<script src="https://cdn.filestorage.io/loader.min.js"></script>
<script>
  FileStorageSDK.mount({
    el: '#fm',
    apiKey: 'fs_live_…',
    s3: {
      proxyBaseUrl: 'https://api.example.com/fm',
      publicObjectBaseUrl: 'https://cdn.example.com',
    },
  })
</script>

Optional: self-host the loader with curl -fsSL https://cdn.filestorage.io/loader.min.js -o loader.min.js. Bootstrap and encrypted assets still require network access to api.filestorage.io.

Loader & iframe runtime

What happens after mount():

  1. Loader POSTs to https://api.filestorage.io/v1/sdk/bootstrap with your key and page host.
  2. API returns a short-lived session token + one-time content key (only if the key and domain are valid).
  3. Loader creates an iframe to https://cdn.filestorage.io/frame.html.
  4. The frame fetches ciphertext from /v1/sdk/assets/…, decrypts with Web Crypto, injects JS/CSS inside the frame only, then mounts the UI.
  5. Parent ↔ frame talk over postMessage (resize/errors/picker/auth header refresh).
CSP directiveAllow
script-srchttps://cdn.filestorage.io
frame-srchttps://cdn.filestorage.io
connect-srchttps://api.filestorage.io + your proxy / HTTP API origin

SDK repository (local demo)

Use this when developing against the reference S3 proxy or customizing editableOptions. Most product embeds only need the CDN loader above.

Terminal
yarn              # install dependencies
yarn --cwd examples/s3-proxy install
yarn dev:sdk      # S3 proxy (:3847) + Vite UI (:3000), reads root .env
yarn build:cdn    # loader + encrypted assets (what production ships)

Vite demo: DEMO_*

Only DEMO_* keys are exposed to the browser bundle. Pick one store:

S3 via reference proxy (local)

.env
DEMO_STORE=s3
DEMO_S3_PROXY_BASE_URL=http://localhost:3847
DEMO_S3_PUBLIC_BASE_URL=https://your-bucket.s3.us-east-2.amazonaws.com

HTTP REST API

.env
DEMO_STORE=http
DEMO_HTTP_API_BASE_URL=https://api.example.com

Mock (no network)

.env
DEMO_STORE=mock
VariableDescription
DEMO_STOREmock | http | s3
DEMO_S3_PROXY_BASE_URLOrigin of S3 proxy (POST /list, /upload, …)
DEMO_S3_PUBLIC_BASE_URLPublic HTTPS origin for object URLs
DEMO_APP_AWS_UPLOAD_URLOptional full URL for multipart upload to your app
DEMO_FM_MAX_CONCURRENT_FETCHESMax parallel fetches from UI (default 30)

Reference S3 proxy: server env

Read by examples/s3-proxy only - never shipped to the browser.

.env
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=
REKOGNITION_REGION=us-east-2
S3_ROOT_PREFIX=
S3_PUBLIC_BASE_URL=
PORT=3847

editableOptions

File: src/config/editableOptions.ts. Brand mark, demo URL fallbacks, color mode, logos, subscription tier, flat page size, recents limit, virtual trash folder, and more. Restart Vite after changes.

Embedding: FileStorageSDK.mount()

Required: el (selector or element with height) and apiKey. Choose exactly one of s3 or http. Returns { unmount: () => void }.

Optional: widget (full | picker | upload | media), accessMode (full | read-only | upload-only). Auth headers may be functions — the loader asks the parent for fresh headers when the iframe needs them.

S3 proxy store

index.html
<div id="fm" style="height: 70vh"></div>
<script src="https://cdn.filestorage.io/loader.min.js"></script>
<script>
  FileStorageSDK.mount({
    el: '#fm',
    apiKey: 'fs_live_…',
    s3: {
      proxyBaseUrl: 'https://api.example.com/file-manager/s3',
      publicObjectBaseUrl: 'https://bucket.s3.us-east-2.amazonaws.com',
      headers: () => ({
        Authorization: 'Bearer ' + (localStorage.getItem('token') || ''),
      }),
      connection: {
        bucket: 'my-bucket',
        region: 'us-east-2',
        rootPrefix: 'uploads/app/',
      },
    },
  })
</script>

HTTP store

JavaScript
FileStorageSDK.mount({
  el: '#fm',
  apiKey: 'fs_live_…',
  http: {
    baseUrl: 'https://api.example.com',
    headers: () => ({ Authorization: 'Bearer ' + token }),
    endpoints: {
      list: '/api/files/list',
      upload: '/api/files/upload',
    },
  },
})

Managed storage

On trial / Solo, Pro, and Business, File Storage provisions a tenant prefix on our AWS account (Solo trial includes 15 GB managed storage - or connect BYO S3). You do not run an S3 proxy or hold AWS keys on Managed. Open Dashboard → Managed storage for status and the recommended mount snippet for your account.

JavaScript
// Shape used when Managed HTTP is enabled for your account
// (exact baseUrl is shown in the dashboard).
FileStorageSDK.mount({
  el: '#fm',
  apiKey: 'fs_live_…',
  http: {
    baseUrl: 'https://api.filestorage.io/v1/storage',
    headers: () => ({
      'X-FileStorage-Api-Key': 'fs_live_…',
    }),
  },
})

HTTP backend contract

All routes are POST, relative to baseUrl:

RouteBodyReturns
POST /api/files/list{ "path": "/" }{ "items": FileEntry[] }
POST /api/files/folder{ "parentPath", "name" }-
POST /api/files/uploadmultipart: path, files[]-
POST /api/files/rename{ "path", "newName" }-
POST /api/files/move{ "path", "destinationFolderPath" }-
POST /api/files/remove{ "path" }-
POST /api/files/search{ "query" }items
POST /api/files/listByType{ "type", "limit?", "cursor?" }items + nextCursor (optional route)

Each item in items is a FileEntry:

FileEntry
interface FileEntry {
  path: string
  name: string
  kind: 'file' | 'folder'
  mime?: string
  size?: number
  updatedAt: number   // epoch ms
  createdAt?: number
  url?: string        // preview URL
}

S3 proxy contract

JSON routes relative to proxyBaseUrl (no /api/files prefix by default):

RoutePurpose
POST /listList folder
POST /listByTypePaginated type filter
POST /folderCreate folder
POST /uploadMultipart upload
POST /rename · /move · /removeMutations
POST /searchSearch

Optional body field connection: { bucket?, region?, rootPrefix? }. Multipart upload fields: parentPath, files, optional bucket/region/rootPrefix.

Uploads via your app (appAwsUploadUrl)

When set on s3, uploads POST multipart to that full URL; all other operations still use proxyBaseUrl. Use this for auth, validation, virus scanning, or metadata before writing to S3.

Framework guides

Each framework has its own start-to-finish guide: create the project, load the SDK, mount a component, connect storage, then test it with a unit test and a Playwright end-to-end test.

Mobile widgets (iOS & Android)

Ship the full file manager or a UI part (picker, upload, media) inside a WebView. Gallery is public at /widgets; production mounts need Pro+ (same plan as white label).

mountWidget
FileStorageSDK.mountWidget({
  el: '#fm',
  apiKey: 'fs_live_…',
  widget: 'picker', // 'full' | 'picker' | 'upload' | 'media'
  s3: { proxyBaseUrl: 'https://api.example.com/fm' },
})

Prefer the hosted shell for native apps: https://cdn.filestorage.io/widget.html?apiKey=…&widget=picker&proxyBaseUrl=…

Full iOS, Android, React Native, and Flutter snippets: Mobile widgets guide.

CORS, authentication, and troubleshooting

SymptomFix
FileStorageSDK is undefinedConfirm loader.min.js returned 200 before mount(). In Next.js / Nuxt load the script in the client layout and wait until window.FileStorageSDK exists.
Blank host / zero heightSet an explicit height on the mount element (e.g. 70vh). The iframe fills the host.
CSP blocks script or frameAllow cdn.filestorage.io in script-src and frame-src; allow api.filestorage.io in connect-src.
Bootstrap / license error in the hostCheck Network for POST /v1/sdk/bootstrap. Fix key, plan, or registered website host.
DOMAIN_NOT_ALLOWEDAdd the page host under Dashboard → Websites (e.g. localhost, app.example.com).
UNPAID_PLAN / INVALID_API_KEYUse an active plan and a non-revoked production API key from the dashboard.
CORS errors on storage callsAllow your app origin on the proxy / HTTP API (POST, Content-Type, multipart).
401 / 403 from your proxyPass headers: () => ({ Authorization: 'Bearer …' }) on http or s3.
404 on /listByTypeImplement the route or restart the example proxy; the SDK falls back to folder walking.
Images without previewsSet publicObjectBaseUrl (and optional connection.rootPrefix) so the client can build preview URLs.
Looking for file-storage.min.jsThat file is no longer published. Use loader.min.js only — see Install.