Let ActiveStorage::Blob#open return a tempfile for manual unlinking
Motivation / Background
Wrapping code in a block is not always (easily) possible, this way it behaves like stdlib Tempfile that can be unlinked manually in addition to the block form that closes for the caller.
A use case I deal with at work involves processing a handful large-ish (10-100MB) CSVs into our models. Due to the way the business logic is structured it is more natural to keep track of open File handles and manually close them out at the end, rather than nesting the outermost layer in a handful of blocks for the current API.
Similarly https://github.com/Shopify/maintenance_tasks/issues/602 could benefit from being in charge of when to unlink the temporary file.
Additional information
Tempfile.create is recommended over Tempfile.new/open per the documentation: https://docs.ruby-lang.org/en/3.2/Tempfile.html
Checklist
Before submitting the PR make sure the following are checked:
- [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
- [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex:
[Fix #issue-number] - [x] Tests are added or updated if you fix a bug or add a feature.
- [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
Unrelated test failures in docs-preview and actionpack (3.3) [rack-head] (3.2 passes entirely).