import { createSeige } from "@seige_sdk/sdk";
const seige = createSeige({ appName: "Receipts" });
input.onchange = async () => {
const file = input.files[0];
const { error } = await seige.files.put(`receipts/${file.name}`, file);
if (error) showMessage(error.hint ?? error.message);
};
const { data: entries } = await seige.files.list("receipts/");
const { data: blob } = await seige.files.get("receipts/september.pdf");
How file storage behaves
put(path, content)accepts aBlob,FileorUint8Array. Paths are relative to the app's folder in the user's account.get(path)returns the file as aBlob.list(prefix)returns entries with paths, types and sizes.delete(path)deletes the file permanently and frees its storage.- A write returns as soon as the file is encrypted and stored in the browser, usually within milliseconds. The SDK publishes it to Seige in the background, in the order it was saved. Call
await seige.sync.flush()before an action that needs the file in Seige, such as signing out. - If two devices change the same file while one is offline, the SDK reports a conflict instead of overwriting the newer version.
seige.files.getConflict()returns both versions so the app can keep one or merge them.
Users can open the files in Seige Files
Files your app saves appear in the app's folder in Seige Files, the file manager in the user's account. File names and metadata are encrypted too. If the user stops using your app, the files stay in their account.
Reading the user's other folders
An app reaches only its own folder by default. To read folders the user already has, ask when the feature needs them. Seige shows a window where the user chooses which folders to share, and the call returns the folders they selected.
const { data: shared } = await seige.request({ access: "read" });
// shared is a list such as [{ folder: "…folder ID…" }]
Limits
- Files up to 100,000,000 bytes.
- Storage counts against the user's Seige storage allowance. Writes that add data fail with
ALLOWANCE_EXCEEDEDwhen it is used up. - Each user needs a Seige account. Account creation is currently open to invited usernames.
Related guides
- A database for a frontend-only app
- End-to-end encrypted storage for a web app
- Files and conflicts reference
This guide is also available as Markdown for coding agents.