0

I am trying to upload image fromandroid to asp.net server. I am following following procedure. convert image from bitmap to byte[] yhen byte[] to string and pass this string to the asp.net web service is this correct way to save image on to the .net server Please Give the solution to upload image from android to asp.net server both client and server side code .

user2346928
  • 3
  • 1
  • 6

3 Answers3

1

The simplest way is convert your bitmap to base64 string :

public String encodeTobase64(Bitmap image)
{
    Bitmap immagex=image;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);

    return imageEncoded;
}

after converting ,you can send the string to webservice, on the server side, you must decode this string to an image ! To convert base64 to image on server side,duckduckgo or google will help you :

https://duckduckgo.com

https://www.google.com/search?sclient=psy-ab&site=&source=hp&btnG=Search&q=convert+base64+to+image+ASp.net+Server

S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
0

Have a look at this tutorial by Microsoft - you'll be able to use the Build the Web Service part for the web service.

For the Android part, you can get inspired by all other questions that try to send a POST request - for example this one.

Community
  • 1
  • 1
Axarydax
  • 16,353
  • 21
  • 92
  • 151
0

If not too late, here is my suggested solution:

  • Server side: you can create a web service or RESTful application on the .NET Framework. Microsoft provides ASP.NET Web API. You can start from their website here
  • Client side: your Android here. You can refer to some of the following: Volley, Retrofit...

If you want to use Volley, you can refer to some following links:

Of course, you can find more available in SO.

Hope this helps!

Community
  • 1
  • 1
BNK
  • 23,994
  • 8
  • 77
  • 87