chainlit
chainlit copied to clipboard
Support Custom File Upload Handlers for Large File Support (e.g., GCS Signed URLs)
Is your feature request related to a problem? Please describe. I’m deploying a Chainlit app to Google Cloud Run, which has a hard 32MB request size limit enforced by Google Front End (GFE). When a user tries to drag and drop a file larger than 32MB into the Chainlit UI, the upload fails silently or throws an error, breaking the experience. This makes it impossible to support large files in environments like Cloud Run, which is otherwise a great hosting option.
Chainlit currently handles file uploads by posting them to the backend over HTTP before sending the message payload over WebSocket. There’s no way to intercept or override this flow to support large files via direct-to-cloud uploads like GCS signed URLs.
Describe the solution you'd like I’d like a built-in way to override the default file upload behavior, for example: • A config option or hook that allows the frontend to request a signed URL from the backend • File is uploaded directly from the browser to external storage (e.g., GCS, S3) • The message payload includes a reference to the uploaded file (e.g., GCS path or download URL)
This would preserve the seamless drag-and-drop UX while supporting files of any size and avoiding backend size limits.
Describe alternatives you've considered • Enabling HTTP/2 in Cloud Run: Doesn’t help, the GFE still enforces the 32MB cap regardless of HTTP version. • Injecting custom JavaScript via custom_scripts: Very brittle. Intercepting file drop events and overriding Chainlit’s upload logic is difficult and breaks easily with frontend updates.
Additional context This feature would benefit many developers using Chainlit on GCP, AWS Lambda, or any serverless platform with strict body size limits. A native way to plug in external upload logic would make Chainlit more robust in production environments.
Let me know if this is something you’d be open to, or if you’d consider a contribution. Thanks for building such a great tool!