Don't try to send the data using anything approaching a text API. You haven't said what postData
is, but try to find some part of its API which deals with streams of binary data instead of text data. Looks for methods along the lines of AppendBytes
, or GetStream
to retrieve a stream you can write your data to.
Pretending that arbitrary binary data is text is a bad idea - you will lose data.
EDIT: One way which tends not to lose data (but is still a bad idea) is to treat binary data as an ISO-8859-1-encoded document. IIRC there is some debate about exactly what ISO-8859-1 contains in positions 128-159, but most encodings at least assume Unicode 128-159 as well.
Your "UTF-8 decoding" of the binary data may look like the correct data because for values 0-127, they're the same - it's only above that that you'll have problems. However, you should still avoid treating this binary data as text. It's not text, and treating it as text is simply a recipe for disaster.
If you could post the headers sent by your browser (including the headers of the part of the multipart that correspond to the image), we can hopefully help you slightly further - but the bottom line is that you should find a way of handing whatever API you're using (that would be useful information too) the raw binary data without going via text.
image/jpeg
.