Skip to content
rmnr
DocsTourSlicesBest PracticeAgentsInstall

Command Palette

Search for a command to run...

New

Slice · AI prompt

File Upload — pluggable upload + URL resolver with storage-adapter contract

Upload + URL resolver behind a storage adapter. localStorage demo, swap to Convex/S3.

Resource detail View source
Copy this prompt into Claude / Codex / Cursor
file-upload.prompt.mdmarkdown
# Install `file-upload` — File Upload — pluggable upload + URL resolver with storage-adapter contract

> Upload + URL resolver behind a storage adapter. localStorage demo, swap to Convex/S3.

📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail   : https://resource.rahmanef.com/slices/file-upload
🧠 JSON catalog   : https://resource.rahmanef.com/api/knowledge?slice=file-upload
🔗 Source         : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/file-upload

## 1. Install

```bash
npx rahman-resources add file-upload
# alias: npx rr add file-upload
```

The CLI copies `frontend/slices/file-upload/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.

## 2. What it ships

- npm: `lucide-react`
- shadcn primitives: `button`

## 3. Wire it up

Default React/Next: run `npx rr add file-upload`, wrap with `<FilesAdapterProvider adapter={...}>`, then use `<FileUploadButton>` / `<FileChip>` and the React hooks. Svelte/SvelteKit: run `npx rr add file-upload --framework sveltekit`, wrap with the Svelte `<FilesAdapterProvider>`, and implement `FilesAdapter` with upload + remove + resolveUrl plus optional subscribeUrl for live invalidation. The bundled localStorage adapter is demo-only; production hosts can target Convex/S3/GCS/R2. The dangerous `files.remove` tool remains server-checked and requires confirmation.

## Rules of engagement

- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice

The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.