A single-owner file drive on Cloudflare's free tiers, made to sit next to agentic-inbox. Files live in R2, folders and share links in a Durable Object's SQLite database, and the whole app is behind Cloudflare Access. The inbox talks to it over a Worker service binding, so it can save attachments to Drive and send big files as links.
- A Material Design 3 interface (MUI v9) modelled on Google Drive: My Drive, Recent, Starred and Trash; list and grid views with image thumbnails; sortable columns; a details panel; light, dark or system theme; works on phones (drawer and New button).
- Right-click menus on files, folders and selections (Preview, Download, Rename, Copy link, Share, Move, Star, File information, Move to trash), on trashed items (Restore, Delete forever) and on empty space (New folder, File upload).
- Multi-select with click, Ctrl/Cmd-click and Shift-click, with a selection bar; drag items onto a folder or a breadcrumb to move them; Undo in the snackbar for moves, stars and trashing.
- Keyboard: Delete (trash), F2 (rename), Enter (open), Ctrl+A, Esc, Alt+C (new folder), Alt+U (upload), arrows in the preview.
- Folders, upload (button or drag and drop anywhere), download, rename, move.
- Files up to 5 GB: the browser uploads 50 MiB parts through an R2 multipart upload, so no request comes near the 100 MB request cap. Progress, cancel, and retry per part.
- Preview for images, video, audio, PDF and text, with Range requests so video seeks and big PDFs open fast.
- Share links:
https://<host>/s/<token>, with an expiry (7 days to 1 year, or never), a download counter, and a revoke button. Anyone with the link can download; everything else needs the owner's Access login. - Search by name, trash with restore (deleted for good after 30 days), and a storage meter against R2's 10 GB free allocation.
- Dark mode; works on phones.
| Thing | Limit | Where it comes from |
|---|---|---|
| Storage | 10 GB-month free | R2 |
| Downloads | Free (no egress fees); 10 M reads/month | R2 |
| One file | 5 GB (set in shared/limits.ts) |
This app |
| One request | 100 MB, so uploads go in 50 MiB parts | Zone plan |
| Worker CPU | 10 ms/request; bytes are streamed, never buffered | Workers Free |
workers/service.ts exports DriveService, a WorkerEntrypoint. The inbox
binds it in its wrangler.jsonc:
Methods: info, list, search, getItem, saveFile (a stream into a
folder path such as ["From email"]), beginUpload / uploadPart /
completeUpload / abortUpload, and createShareLink. Service bindings stay
inside Cloudflare and can't be called from the internet.
npm install- Create the bucket:
npx wrangler r2 bucket create agentic-drive - Zero Trust → Access → Applications:
- a self-hosted app for
drive.<your domain>with an allow policy for your email; put its Application Audience (AUD) tag inPOLICY_AUDinwrangler.jsonc. Keep it a separate app from the inbox's: Access's team session already means one sign-in covers both, and a shared app would make every Mail login hop through the Drive hostname too; - a second self-hosted app for
drive.<your domain>/swith a Bypass policy for Everyone, so share links open without a login.
- a self-hosted app for
- Set
PUBLIC_URLand theroutespattern inwrangler.jsoncto your host. npm run deploy
npm run dev # Access is skipped in dev
npm test # Workers runtime tests (vitest + @cloudflare/vitest-plugin)
npm run typecheck- Every request except
/s/*needs a valid Access JWT for a person (service tokens are refused). - Files are served with
X-Content-Type-Options: nosniffand a sandbox CSP, and HTML, SVG, XML and JavaScript are always downloads, so an uploaded file can't run script on the Drive origin. - Share tokens are 24 random bytes. Share pages send
noindexandno-referrer. Trashing a file turns its links off at once.