diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 45d85a3d3f..e77689cb10 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,3 +1,15 @@ +* Fixes proxy downloads of files over 5mb + + Previously, trying to view and/or download files larger than 5mb stored in + services like S3 via proxy mode could return corrupted files at around + 5.2mb or cause random halts in the download. Now, + `ActiveStorage::Blobs::ProxyController` correctly handles streaming these + larger files from the service to the client without any issues. + + Fixes #44679 + + *Felipe Raul* + * Saving attachment(s) to a record returns the blob/blobs object Previously, saving attachments did not return the blob/blobs that diff --git a/activestorage/app/controllers/concerns/active_storage/streaming.rb b/activestorage/app/controllers/concerns/active_storage/streaming.rb index 8c16adefdc..4ff4727ff9 100644 --- a/activestorage/app/controllers/concerns/active_storage/streaming.rb +++ b/activestorage/app/controllers/concerns/active_storage/streaming.rb @@ -3,6 +3,7 @@ require "securerandom" module ActiveStorage::Streaming + extend ActiveSupport::Concern DEFAULT_BLOB_STREAMING_DISPOSITION = "inline" include ActionController::DataStreaming diff --git a/activestorage/test/controllers/blobs/proxy_controller_test.rb b/activestorage/test/controllers/blobs/proxy_controller_test.rb index 443539aded..c45105ffe4 100644 --- a/activestorage/test/controllers/blobs/proxy_controller_test.rb +++ b/activestorage/test/controllers/blobs/proxy_controller_test.rb @@ -85,6 +85,14 @@ class ActiveStorage::Blobs::ProxyControllerTest < ActionDispatch::IntegrationTes ) end end + + test "uses a Live::Response" do + # This tests for a regression of #45102. If the controller doesn't respond + # with a ActionController::Live::Response, it will serve corrupted files + # over 5mb when using S3 services. + request = ActionController::TestRequest.create({}) + assert_instance_of ActionController::Live::Response, ActiveStorage::Blobs::ProxyController.make_response!(request) + end end class ActiveStorage::Blobs::ExpiringProxyControllerTest < ActionDispatch::IntegrationTest