Send image from android to web server api

0

I need help please. I am trying to make a post of an image from android studio to a web api in .NET but I am not managing to do it. I've tried some codes on the internet but they're all very different, and those that I test do not make it work. The rest of the calls REST I do with volley. Can someone help me with this issue with some tried-and-tested example code, no matter what library?

Thank you very much

    
asked by Ezequiel 06.03.2017 в 17:14
source

1 answer

1

Transform your image to Base 64 and send the text as a normal post

BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap image BitmapFactory.decodeFile("tu/ruta/de/foto.jpg", options);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 70, baos);
byte[] byteArray = baos.toByteArray();
String base64 Base64.encodeToString(byteArray, Base64.DEFAULT);
    
answered by 06.03.2017 в 17:43