Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services

This commit is contained in:
Felipe 2022-05-15 12:47:26 -03:00
parent 06610c49fb
commit e4eab9892f
3 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -3,6 +3,7 @@
require "securerandom"
module ActiveStorage::Streaming
extend ActiveSupport::Concern
DEFAULT_BLOB_STREAMING_DISPOSITION = "inline"
include ActionController::DataStreaming

View File

@ -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