App SDK

files

Store and read files in the app's private storage.

Server code only. Every function takes your fetch handler's env first. Files are kept under the app's own private prefix; your app never holds storage credentials. See Files for a full example.

files.put

files.put(env, key: string, body: string | ArrayBuffer | Uint8Array | Blob, contentType?: string): Promise<void>

Uploads a file. Replaces any file with the same key. Throws if the upload fails.

keystringrequired

The file's name in the app's storage, for example receipts/usr_01J9/2026-10-06.pdf. Use / to group files.

bodystring | ArrayBuffer | Uint8Array | Blobrequired

The file content. Up to 25 MB.

contentTypestring

For example application/pdf or image/png.

files.get

files.get(env, key: string): Promise<Response | null>

Downloads a file. Returns the Response (read it with .arrayBuffer(), .text() or pass .body on), or null if it does not exist.

files.url

files.url(env, key: string): Promise<string>

A link to download the file that works for 5 minutes, for anyone who has it. Check the signed-in person should see the file first.

files.delete

files.delete(env, key: string): Promise<void>

Deletes the file.

Errors

Each function throws an Error whose message starts with Inhaus files: and includes the status, for example when a file is over 25 MB (413).