1

I have a multipart / form-data form to upload a csv file to a rest easy (JAX RS) webservice. This file can contain iso-8859-1 characters like for example é. When I upload the file through Firefox these characters are garbled and they end up like a ?. When I upload the file through Internet Explorer everything works fine.

I've done a lot of reading and found out that there's a problem in firefox combining multipart / form-data and the charset attribute (enctype='multipart/form-data; charset=ISO-8859-1') doesn't work.

So I've tried setting <meta http-equiv="Content-Type" content="text/csv; charset=iso-8859-1" /> in my HTML page (I also tried setting text/html or multipart/form-data in stead of text/csv but none of that seems to make a difference.

I went through the rest easy api and found something about 'overwriting the default fallback content type for multipart messages'. The default fallback when no content type is found is us-ascii. The characters I try to process (é,..) don't exist in us-ascii so it makes sense they end up garbled. Overriding this default fallback content type doesn't seem to help either (see: http://docs.jboss.org/resteasy/docs/1.2.GA/userguide/html/Multipart.html)

So am I right when I say that Internet Explorer sends the content-type+charset correctly in the http header, so everything goes well. And that firefox messes things up while trying to send the content-type/charset while combined with multipart/form-data? I have done my searching through stackoverflow but none of the approved solutions seem to work in my case.

Has anybody had this specific problem before? (multipart / form-data file upload using Jboss rest easy framework)? Something else I can try?

Thanks in advance!

Yannick

Yannick
  • 11
  • 1
  • 2
  • I have done some testing and changed the http header using tamperdata and it seems to be a mime type (content-type) issue rather than an encoding issue. When uploading a file in Internet Explorer the content-type of the uploaded CSV file is application/vnd.ms-excel. While doing the same action in Firefox the content-type is text/csv. When I change the content type to application/vnd.ms-excel using Tamperdata it works fine. (Tamperdata is an addon where you can change your http header before sending it to the server.) – Yannick Aug 08 '10 at 19:22
  • So first of all, why is text-csv file being threated in an other way than application/vnd.ms-excel? And how can I manually set the content-type of the file I'm going to upload? Or should I look in the server side direction? Should I parse the text/csv file differently in Java? – Yannick Aug 08 '10 at 19:27

0 Answers0