Skip to content

Encoding::UndefinedConversionError when IO.copy_streaming binary files #2779

Closed
@janko

Description

@janko

We're trying to make Refile compatible with JRuby. We've almost made it (and it was fairly easy, I have to admit!), but we have one remaining bug.

In Refile we're using file wrappers, that is, we wrap an actual IO into a class which responds to #read, #eof?, #close and #size. This is all it takes to act as a real IO, because we can now pass them to IO.copy_stream, and it will work. However, when we wrap images (which are binary), IO.copy_stream raises an Encoding::UndefinedConversionError. The error doesn't happen if we pass the image IO directly, only when we use a wrapper (ActionDispatch::Http::UploadedFile or Refile::File, they both fail).

We weren't able to reproduce the problem (I posted an attempt of reproducing it), so we were hoping you could help us out. The pull request is refile/refile#187. I think you only need to run bundle install to set up the test suite, the branch is jruby on my fork.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions