-
Notifications
You must be signed in to change notification settings - Fork 64
Fix unknown file size when downloading file #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Nugine <[email protected]>
|
@copilot retry |
Fixed and ready for review! The issue is resolved in commit 1a58b9b. The fix modifies All tests pass and linter checks complete successfully. |
|
@copilot |
Reverted the incorrect fix that used size_hint() in StreamWrapper. Created a new SizedByteStream wrapper in s3s-fs that properly tracks consumed bytes and provides accurate remaining_length(). This allows the Content-Length header to be set correctly in HTTP responses. Co-authored-by: Nugine <[email protected]>
You're absolutely right. I've fixed the issue properly in commit cfc168f. The previous approach was incorrect because:
The correct solution creates a
This is now used for GetObject and UploadPartCopy operations in s3s-fs. |
Description
This PR fixes the issue where browsers display "unknown file size" when downloading files through s3s-based services (like RustFS). The problem was that
StreamingBlobwraps generic streams that don't track remaining bytes, preventing the HTTP layer from setting theContent-Lengthheader in responses.Changes Made
Created a new
SizedByteStreamwrapper incrates/s3s-fs/src/utils.rsthat:ByteStreamtrait with accurateremaining_length()methodinitial_length - consumedpoll_next()Updated
crates/s3s-fs/src/s3.rsto:SizedByteStreamwrapper for file streams in GetObject operationsSizedByteStreamwrapper for UploadPartCopy operationsStreamingBlob::new()Added
pin-project-litedependency tocrates/s3s-fs/Cargo.tomlfor the pin projection macro.This solution properly tracks remaining bytes as the stream is consumed, allowing the HTTP layer to set Content-Length headers correctly based on the
ByteStream::remaining_length()implementation.Related Issues
Related to rustfs/rustfs#902
Testing
The changes are surgical and focused on s3s-fs, preserving all existing functionality while enabling proper Content-Length headers for file downloads.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.