Add option to ActiveStorage::Blob to set extract_content_type_from_io #32833
activestorage CHANGELOG.md addition
This adds a boolean extract_content_type_from_io to ActiveStorage::Blob
This patch aims to address:
It fixes bugs where a content_type is automatically extracted from the input and gives an inaccurate result. This is due to a bug in the Marcel::MimeType gem that is called in the extract_content_type method (which was called by default in the #upload method, which is in turn called by #build_after_upload and #create_after_upload)
Added document comments to
Finally, if your pull request affects documentation or any non-code
Thanks for contributing to Rails!
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.
Please see the contribution instructions for more information.
Looks like this change would affect the Rails Guides too:
http://edgeguides.rubyonrails.org/active_storage_overview.html#attaching-file-io-objects in the section 3.3 Attaching File/IO Objects
I've added this to the commit and squashed it in.
This adds a boolean argument called identify to ActiveStorage::Blob methods #create_after_upload, #build_after_upload and #upload. It allows a user to bypass the automatic content_type inference from the io.