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 .

8
  • Yes, it's the correct way to save image on the server. Commented Mar 13, 2014 at 7:03
  • but i am not able to save image on to the server Commented Mar 13, 2014 at 7:04
  • Are you experiencing problems with any step of your solution? If so, please ask specifically about them. Commented Mar 13, 2014 at 7:04
  • is the web service being called? Do the correct bytes arrive? do you receive an exception in your Android app? Commented Mar 13, 2014 at 7:05
  • problem is that i am passing parameter string to the .net web service it says that to much length. Commented Mar 13, 2014 at 7:07

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.