kemal icon indicating copy to clipboard operation
kemal copied to clipboard

File upload: Unexpected byte 0xff in UTF-8 byte sequence from parse_multipart

Open srpelissier opened this issue 9 years ago • 3 comments

Using the example found at http://kemalcr.com/docs/file_upload/ causes an error in Kemal.

If I upload an image file curl --form "[email protected]" http://localhost:3000/upload, there is an unexpected character Unexpected byte 0xff in UTF-8 byte sequence from parse_multipart. The return code: 500.

In comparison, if I upload a text file curl --form "[email protected]" http://localhost:3000/upload, the first character is lost: puts "HEADERS: #{f.headers}" shows "his a test" while I was expecting "this a test". The return code: 200.

Code:

require 'kemal'
module Kemal1
  post "/upload" do |env|
    parse_multipart(env) do |f|
      puts "HEADERS: #{f.headers}"
    end
  end
  Kemal.run
end

srpelissier avatar Jan 03 '17 12:01 srpelissier

It looks like that its just using multipart.cr. So you may want to create an issue there. However, there should be some specs here.

EDIT: looking at multipar.cr, it looks like it was updated recently (today). You might want to try updating your dependencies.

samueleaton avatar Jan 04 '17 00:01 samueleaton

I've got a fork of kemal with this updated. It's only temp while testing this fix. I'm sure kemal will have a new release soon.

perhaps use crisward/kemal while you're waiting...?

crisward avatar Jan 04 '17 13:01 crisward

thank you, it's working now

srpelissier avatar Jan 04 '17 15:01 srpelissier