Upload without a server

Let people upload from a static site, a public form or a prototype with nothing but an upload preset's ID. Files go straight to CalmLens, the uploader sees whether their file was accepted, and you review uploads in the portal. When you need to know who uploaded, or to show uploads to other visitors, upload with your server instead.

1. Create a preset open to anyone

In Portal › Upload presets, create a preset open to anyone with its ID. Anyone who loads your page can upload through it, so its settings are what protect your usage:

SettingValue
Daily upload limitRequired. The most uploads each visitor (IP address) makes per UTC day; further uploads fail with 429 upload-preset/daily-limit-reached.
File types and maximum sizeOnly what your page expects, such as image/* up to 10 MiB, within each type's upload limit. Anything else is refused before it's stored.
Allowed sitesYour site's origins, so other websites can't use the preset from a browser. Scripts outside a browser can send any Origin header, so keep the daily limit. Leave it empty for mobile apps, which send no Origin header.
Show the decision to the uploaderOn, so your page can tell people whether their upload was accepted.
Keep content after moderationOn only if your page shows uploads back. When off, each file is deleted once it's moderated, and its record and report remain.

The preset ID is safe to put in your page: it can only upload through this preset, into its folder, with its settings. Upload presets explains every setting.

2. Add the upload widget

Install calmlens in your front end and add the upload widget with the preset ID alone:

import { type CalmLensUpload, CalmLensUploader } from "calmlens/react";

export function PublicPhotoUploader({
  onUploaded,
}: {
  onUploaded: (upload: CalmLensUpload) => void;
}) {
  return (
    <CalmLensUploader
      uploadPresetId="preset_4Lk8Qw2Xm9Rt5Vb3Nc7P"
      accept="image/*"
      maxFileSize={10 * 1024 * 1024}
      onUploaded={onUploaded}
    />
  );
}

In a React Native or Expo app, use the React Native uploader with the same settings. To build your own interface, create a CalmLensAppClient with the preset ID and call client.assets.classify(), which waits for the decision.

3. Show the uploader the decision

Each upload returns its asset ID, name and upload time, and its moderation status when the preset shows decisions. The widget turns the status into a message for the uploader:

StatusWhat the uploader sees
allowed or limitedTheir file was accepted.
age-restrictedTheir file was accepted and is shown only to people who can see sensitive content.
pendingTheir file was uploaded and is still being checked. The widget checks for up to 15 seconds.
blocked or purgedTheir file can't be used because it breaks your rules.

The browser never receives the moderation report, metadata or URLs, only the status of its own upload.

4. Show the upload back to the uploader

To show the uploader their file, turn on Keep content after moderation, set the preset's visibility to public, and render the asset component with the asset's URL, built from the asset ID in onUploaded with cdn.getAssetUrl on a CalmLensAppClient created with your project ID. It shows files the viewer can't see as unavailable without requesting them.

The CDN serves a public file only once it has passed moderation, because Block assets until moderation finishes is on by default. Turning it off serves the file as soon as its upload completes, before moderation decides.

The preset does not let a browser list uploads, but a public file is accessible to anyone with its eligible CDN URL. The uploader can share that URL; this is not private delivery. Use private assets and server-side access checks for private submissions. A shared gallery needs somewhere to store and list asset IDs, such as your backend.

5. Review uploads

Uploads appear in the preset's folder in the portal, with each one's moderation report. To hear about new uploads and decisions, connect Slack or email in Portal › Webhooks & connectors.

When to add a server

Add a server when you need to do any of the following. Usually it only has to sign upload tokens, so files still go straight to CalmLens; send files through your server only when it must handle the file itself.

  • Know who uploaded a file, or attach it to a record such as a post, with an externalId that only your server can set.
  • Show uploads to other visitors, which needs their asset IDs stored somewhere.
  • Limit uploads per signed-in user instead of per IP address.
  • Publish from a decision your server reads from CalmLens. The status in the browser is for the uploader's feedback only, because people can change what their browser sends.

Calmform is a static feedback form built this way.

Last updated

Signing in

Signing out

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies