File Storage
Docs menu

Getting Started

Introduction

Add one CDN script, call mount() with your API key and storage backend. The UI loads encrypted into a sandboxed iframe after license checks.

Choose your path

Pick the option that best describes your project to jump to the right guide.

How it works

Production embeds use a tiny public loader. You never ship the full UI as readable CDN JS/CSS.

  1. Your page loads https://cdn.filestorage.io/loader.min.js (exposes window.FileStorageSDK).
  2. You call FileStorageSDK.mount({ el, apiKey, s3 | http }).
  3. The loader checks your key + registered domain via POST /v1/sdk/bootstrap, then mounts a sandboxed iframe from cdn.filestorage.io/frame.html.
  4. Inside the iframe only: encrypted assets are fetched from the API, decrypted, and injected. Your parent page never sees the product bundle in View Source.

Every production mount needs an apiKey plus one storage backend:

  • S3 proxy - your server holds AWS credentials and talks to your bucket.
  • HTTP API - your backend implements the list / upload / rename / move / remove contract.
  • Managed - we host the bucket (Trial includes 1 GB); use the HTTP adapter from your dashboard (no AWS keys on your side).

Quick start (HTML)

Minimum working embed once you have a key, a registered website, and a storage proxy URL:

index.html
<!-- 1. Container with explicit height -->
<div id="fm" style="height: 70vh"></div>

<!-- 2. Public loader (only CDN script you need) -->
<script src="https://cdn.filestorage.io/loader.min.js"></script>

<!-- 3. Mount after the loader -->
<script>
  const { unmount } = FileStorageSDK.mount({
    el: '#fm',
    apiKey: 'fs_live_…', // from Dashboard → Keys
    s3: {
      proxyBaseUrl: 'https://api.example.com/fm',
      publicObjectBaseUrl: 'https://cdn.example.com',
      headers: () => ({
        Authorization: 'Bearer ' + (localStorage.getItem('token') || ''),
      }),
    },
  })
  // Call unmount() when leaving the page / destroying the component
</script>

Install checklist

No npm package is required for production embeds. Follow these steps in order.

1. API key and website

  1. Create an account and pick a plan.
  2. In the dashboard, create an API key (fs_live_…).
  3. Under Websites, register every host that will call mount() (e.g. localhost, app.example.com). Once any site is registered, unlisted hosts get DOMAIN_NOT_ALLOWED.

2. Load the CDN loader

Add the public loader once in your root layout or page (before any mount() call):

index.html
<script src="https://cdn.filestorage.io/loader.min.js"></script>

Editor plugins load after the loader — see editor plugins.

3. Verify the loader

JavaScript
// Browser console on your site (after the script tag):
typeof FileStorageSDK.mount === 'function'  // → true

Self-host the loader (optional)

You may host loader.min.js yourself. The encrypted UI still comes from api.filestorage.io at runtime (online bootstrap is required):

Terminal
curl -fsSL https://cdn.filestorage.io/loader.min.js -o loader.min.js

Embed with mount()

Call FileStorageSDK.mount() with a container that has an explicit height, your apiKey, and either s3 or http. Pick your framework — your choice is remembered across the docs:

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

CSP, iframe, and layout

The UI runs in a cross-origin sandboxed iframe. Give the host element a real height and allow the CDN + API in your Content Security Policy:

DirectiveAllow
script-srchttps://cdn.filestorage.io (loader + optional editor plugins)
frame-src / child-srchttps://cdn.filestorage.io (frame.html)
connect-srchttps://api.filestorage.io (bootstrap + encrypted assets) and your S3 proxy / HTTP API origin

Configuration

Pass store options (s3 / http), optional widget, and accessMode at mount time. Auth headers can be functions — the loader refreshes them over postMessage when the iframe needs them. Full option reference: Integration guide → mount().

S3 proxy

The SDK repo includes a reference Node proxy in examples/s3-proxy/. yarn dev starts it on port 3847 together with the demo UI. It exposes POST /list, /upload, /folder, /rename, /move, /remove, /search, and optional /listByType.

Local demo environment variables

Only needed when running the SDK repository demo locally. Copy env.example → .env in the SDK repo root. Production embeds do not use DEMO_* - pass options to mount() instead.

VariablesRead by
AWS_*, S3_*, PORT, REKOGNITION_REGIONS3 proxy only (server-side)
DEMO_*Vite demo - inlined into the browser bundle
.env
# Browser demo (public)
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
DEMO_FM_MAX_CONCURRENT_FETCHES=30

# S3 proxy (secret)
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=
PORT=3847

Next steps