File Processing
Upload PDFs and stream structured student record extraction in real time.
How it works
The file processing pipeline runs in three stages:
- Upload — the browser uploads the PDF directly to Nexa using a short-lived token (your API key never leaves the server)
- Process — Nexa stores the file in UploadThing and dispatches it to the OCR + AI pipeline automatically
- Stream — receive live progress events; query structured records when done
The upload is a two-phase flow managed automatically by the SDK:
This means the file never passes through your app's server — it goes directly from the browser to Nexa.
Step 1 — Upload a file
React (recommended)
Drop <UploadZone /> anywhere in your UI. It handles the entire two-phase flow with a progress bar — no extra code needed.
The onUpload prop is optional. When omitted, <UploadZone /> uses the built-in useUploadFile hook automatically.
Manual (hook)
Use useUploadFile when you need custom UI or programmatic control:
Info
uploadProgress (0–100) reflects actual byte-transfer progress. isDispatching
is true once all bytes are sent and Nexa is storing the file + dispatching the pipeline.
Step 2 — Processing is automatic
There is no separate "submit" step. Once the file upload completes (POST uploadUrl returns 200), Nexa has already:
- Stored the file in UploadThing and obtained a permanent CDN URL
- Provisioned your user in the pipeline database
- Dispatched the OCR job to FastAPI
The fileId returned is your handle for polling progress and querying records.
Step 3 — Stream progress
Server-side (async generator)
Use streamProgress in a server action or API route to get live events as they arrive:
Client-side (React hook)
In a React component, use useFileProgress — it connects to /api/nexa/progress/:fileId via EventSource automatically:
FileProgressEvent shape
Step 4 — Handle the webhook
When extraction finishes, Nexa sends a file.completed event to your webhook URL. The SDK verifies the signature and calls your onFileComplete callback automatically.
For the full payload shape see Webhooks.
What's next
- Documents — query student records and analysis jobs after processing
- Webhooks — full payload types and Convex integration
- React Components — UploadZone — drop-in upload UI