Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
schalk
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Writing files to a server and Character decoding failed

Hi All,

 

I am writing some data to the server which involves a JSON string as well as some images. I encode the JSON string using URLEncodedPostData with a UTF-8 character encoding and I am writing the bytes of the file to the same output stream. For some reason on the server side, Tomcat in this case, I see a bunch of Character decoding failed exceptions.

 

Does anyone know where I might be going wrong from this high level overview? Any suggestions as to an article or tutorial? All help much appreciated.

 

Kind Regards,

Schalk 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

What type of encoding are you declaring in your HTTP header?

 

What type is accepted by the server? (Accept header)

 

Please use plain text.
Developer
schalk
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

Hi there,

 

I was using iso-..... and it seems the server wanted UTF-8. I changed this around and that seemed to solve the character encoding problem. The issues I have now is that everything seemingly get's written to the server (server responds with 200 and success reply) but, the images that I write to the output stream are never written to a file on the server side.

 

There are images created on the server but they are all of 0 bytes in length. Is there anything specifically needed when writing images from the BB to a server such? Thanks!

 

Kind Regards,

Schalk 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

How are you encoding the image data?

 

What method are you using? POST?

 

Are you setting the data length in your POST?

 

 

 

Please use plain text.
Developer
schalk
Posts: 72
Registered: ‎06-29-2009
My Device: Not Specified

Re: Writing files to a server and Character decoding failed

Hi there,

 

I am reading the file from the file system/sd card using an implementation of the JSR75 spec which then returns the file as a byte array. I then write this array out to the OutputStream of the HTTPConnection. I have heard that some transport protocols required base64 encoding, is this something I need for this scenario or is there something else? Thank you for all of your help.

 

Kind Regards,

Schalk 

Please use plain text.