[PromptInput]: Support for hosted URL for files
#89 aberto em 10 de set. de 2025
Métricas do repositório
- Stars
- (2.073 stars)
- Métricas de merge de PR
- (Métricas PR pendentes)
Description
According to the documentation of UIMessage, a FileUIPart can either use a hosted URL or a data URL. At the moment, <PromptInput /> uses data URLs.
This works, but has some drawbacks worth mentioning:
-
Increased payload size: All file bytes are inlined directly into the message as a Base64 string. This makes every message carry the entire file contents instead of just a short reference.
-
33% size inflation: Base64 encoding adds overhead — files end up ~33% larger than their binary size, plus a small
data:...;base64,prefix. -
Persistence: If you want persistence of chat history and messages, you need to store the data URL in the DB somewhere. For big enough files, this obviously is not very scalable. You typically store only the reference to the file in the DB, and the actual file in a storage somewhere else, like Vercel Blob or S3.
Not really sure what the best solution would be here, perhaps some props could be exposed in <PromptInput /> where we could write our own logic for what happens when a file is added/removed? But that might introduce some heavy refactoring...