# Add safe file collection to an agent-built app

Store a sample file in object storage, keep metadata in SQL, and authorize its download on the server.

## How do I add file uploads without exposing storage credentials in the browser?

Send uploads to the app backend. Validate size and format before writing bytes with env.FILES, store metadata in env.DB, and check session ownership before serving an attachment. Storage credentials stay server-side.

1. Accept a bounded multipart upload on the backend.
2. Allow only the documented formats and inspect binary signatures.
3. Keep file bytes in object storage and session-scoped metadata in SQL.
4. Download through an authorized backend route with attachment and nosniff headers, then compare the downloaded bytes.

```javascript
await env.FILES.put(key, bytes, {
  httpMetadata: { contentType: 'application/octet-stream' }
});
// Store metadata in env.DB; check the session before download.
```

## Limits and evidence

The demo allows 3 active files per session, at most 128 KiB each: TXT, JSON, PNG, JPEG and PDF. Synthetic samples only. It is not a malware scanner or a production document portal.

Public browser verification date: 2026-11-30. All example data is synthetic; no customer, performance or revenue claims.

Unclaimed apps expire after 72 hours; persistent use requires a human ownership claim.

[Deployment docs](https://backendshare.com/docs)
