1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib
Janko Marohnić 32b2942946
Restore UploadedFile compatibility with IO.copy_stream
In https://github.com/rails/rails/pull/28676 the `#to_path` method was
added to `ActionDispatch::Http::UploadedFile`. This broke usage with
`IO.copy_stream`:

  source = ActionDispatch::Http::UploadedFile.new(...)
  IO.copy_stream(source, destination)
  # ~> TypeError: can't convert ActionDispatch::Http::UploadedFile to IO (ActionDispatch::Http::UploadedFile#to_io gives Tempfile)

Normally `IO.copy_stream` just calls `#read` on the source object.
However, when `#to_path` is defined, `IO.copy_stream` calls `#to_io` in
order to retrieve the raw `File` object. In that case it trips up,
because `ActionDispatch::Http::UploadedFile#to_io` returned a `Tempfile`
object, which is not an `IO` subclass.

We fix this by having `#to_io` return an actual `File` object.
2019-02-23 23:36:58 +01:00
..
abstract_controller AbstractController::Translation#t: dup options 2019-02-15 18:21:41 +02:00
action_controller Pass the template format to the digestor 2019-02-15 17:27:33 -08:00
action_dispatch Restore UploadedFile compatibility with IO.copy_stream 2019-02-23 23:36:58 +01:00
action_pack Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
abstract_controller.rb Add autoload hook for AbstractController::ActionNotFound 2018-11-28 14:21:19 -05:00
action_controller.rb Include default headers by default in API mode 2018-04-06 15:13:28 -04:00
action_dispatch.rb Bump license years for 2019 2018-12-31 10:24:38 +07:00
action_pack.rb Bump license years for 2019 2018-12-31 10:24:38 +07:00