I am using Java (Android) to attempt to upload a file to a web server, using HttpURLConnection as recommended. I have had difficulties sending data as a POST request in the past but successfully achieved it after a few hours. This data was simple JSON data so conversion was not of major concern and I used a buffered writer to achieve the goal.
Now I would like to upload real files using multipart/form-data and am expecting a mix of different encodings to be passed of which, binary, is unsupported by both OutputStreamWriter (which only takes string or char[] args) and BufferedWriter (which only allows similar args).
I will need to send a mixture of binary and textual data to a server and am wondering, what is the best way to do this?
I will need to use the raw OutputStream to send bytes but will this conflict with OutputStreamWriter + BufferedWriter layers when it comes time to send char arrays?
Or perhaps should I convert the UTF8 text to binary using a specific method and send it all using byte arrays?
Thank you for any help provided