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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.10.4
    • 2.10.5, 2.11.5, 2.12.2
    • GridFS
    • 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

    Description

      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.`

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: