Android Upload string image to c#

Asked

Viewed 42 times

1

I am sending Android images to the server in C# but when I try to make the conversion gives error in this conversion.

On android do this conversion:

ByteArrayOutputStream stream = new ByteArrayOutputStream();

bitmapPhoto.compress(Bitmap.CompressFormat.JPEG, 50, stream);
final byte[] img_byte = stream.toByteArray();

final String imageString = Base64.encodeToString(img_byte, Base64.DEFAULT);

On the c# server I get the string and do the image conversion again:

byte[] novaFoto = Convert.FromBase64String(NovaFoto.FotoString);

using (MemoryStream stream = new MemoryStream(novaFoto))
{
    Image image = Image.FromStream(stream);
}

Sometimes it gives error when making the conversion to byte[] and sometimes gives error in Image.Fromstream

Can someone help me with that?

  • You are sending this string 64 via POST, correct? Checked if she is not being truncated?

  • How I can see that?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.