Performance: File uploads and streaming
HIGH IMPACT
This affects page load speed and interaction responsiveness by managing how large files are sent and processed without blocking the main thread.
export const action = async ({ request }) => { const formData = await request.formData(); const file = formData.get('file'); const stream = file.stream(); await saveFileStream(stream); return new Response('Upload complete'); };
export const action = async ({ request }) => { const formData = await request.formData(); const file = formData.get('file'); const buffer = await file.arrayBuffer(); // Process entire file buffer synchronously await saveFile(buffer); return new Response('Upload complete'); };
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous full file read | Minimal | 0 | 0 | [X] Bad |
| Streaming file upload | Minimal | 0 | 0 | [OK] Good |