Fix Rails 7 Regression - ActiveStorage Content Disposition #43637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When upgrading our app from 6.1.4.1 to 7, we noticed that the following code no longer functioned:
Originally, this worked as expected, redirecting the file and triggering the browser to download it as an attachment. After the upgrade, it redirected to the attachment, but the disposition was always
inline
.Root Cause
After a brief investigation, I determined that this regression was introduced in ab8e3d22 where @dhh refactored/simplifed the
ActiveStorage
ProxyController
code, but forgot to pass thedisposition
parameter into the callers of his newly created method (send_blob_stream
).Resolution
This PR passes the missing option to the
Blob:ProxyController
and theRepresentations:ProxyController
'ssend_blob_stream
call, and added tests to ensure these do not regress in the future.We are using this solution locally in our Rails 7 Upgrade to great effect.