Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2210

GridFS does not write data correctly when given String in UTF-8 encoding

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.10.5, 2.11.5, 2.12.2
    • Affects Version/s: 2.10.4
    • Component/s: GridFS
    • Labels:
    • Environment:
      Mac OS X, Ruby 2.1.10 (ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin19.0]), mongoid 5.4.1
    • Fully Compatible

      This code fails :

      ```

      grid = Mongoid.default_client.database.fs

      file_name = 'test_fern.txt'
      grid.open_upload_stream(file_name) do |stream|
      stream.write('Fèrn')
      end

      grid.open_download_stream_by_name(file_name) do |stream|
      puts stream.read
      end

      ```

       

      Whereas using 'Fern' succeeds. It's the presence of the special utf8 character that causes it to fail with this error:

      `Mongo::Error::UnexpectedChunkLength:
      Unexpected chunk length. Chunk has length 5 but expected length 261120 or for it to be the last chunk in the sequence.`

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            michaelehagar@gmail.com Michael Hagar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: