You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimize FileUploader to avoid loading full stream into memory during upload #3692
The current FileUploader implementation in packages/serverpod_client/lib/src/file_uploader.dart uses http.ByteStream(stream).toBytes() to convert the entire stream to bytes before uploading. While this fixes the immediate issue with stream reading by using an Uint8List for buffer, it still loads the complete file into memory before starting the upload.
Problem
For large file uploads, this approach can cause:
High memory usage
Potential out-of-memory errors on devices with limited RAM
Poor performance due to buffering overhead
Proposed Solution
Implement a streaming upload mechanism that can send data directly from the stream to the HTTP request without buffering the entire content in memory first. This would involve:
Using the stream directly in the HTTP request body
Ensuring proper chunked transfer encoding
Maintaining compatibility with the existing upload flow
Context
This issue was identified during the review of PR #3691 which fixed the immediate stream reading issue but introduced the memory buffering concern.
Activity