1

I have a bitmap or lets call it a file that I want to upload to my c# server, this bitmap (file) is captured via camera and saved into the sd card, but I have to no idea how exactly should I send it to my c# server. I don't know exactly what should I send in my request and what should be my server function's parameter to receive the file. Any help would be appreciated.

I've found this which shows how to send a file to server but it's using a php server side coding so I couldn't completely understand the process.

I'm not asking for code or anything, just a direction or explanation so I understand the concept. Thanks in advance

arash moeen
  • 4,533
  • 9
  • 40
  • 85
  • You talk about a "bitmap". I'm pretty sure this means two different things for Android and .Net. You'll probably have to chose some intermediate format, for example .png file image. – RenniePet Mar 13 '15 at 15:53
  • @RenniePet You're right, by default the image captured by user is saved as .jpg file. I have changed the bitmap to file. Thanks for correction – arash moeen Mar 13 '15 at 16:14

3 Answers3

1

You need to do the following

  1. Create a api call that will accept the file and store that file somewhere on the server.
  2. You need to upload the image to the server with the help of the api call by passing the image file in it

Uploading image to server example How do I send a file in Android from a mobile device to server using http?

Refer this for uploading with progress bar

Community
  • 1
  • 1
Fahim
  • 12,198
  • 5
  • 39
  • 57
  • Thanks Fahim, I'm gonna check the link you've posted. So on my server I'll deal with it as a normal uploaded file as there's uploaded for example from the file input in html? – arash moeen Mar 13 '15 at 14:59
  • Fahim, using the link you provided it seems it will work perfectly but is it also possible to modify it to actually track the progress of upload ? – arash moeen Mar 13 '15 at 15:00
0

Doesn't need to upload the images, just convert Image into Base64 an then upload this string to the specific field.

You can easily upload and retrieve images.

Yannis
  • 1,682
  • 7
  • 27
  • 45
Kashif Ahmed
  • 803
  • 9
  • 20
0

Before pushing it to server, convert your bitmap to string and push it using api. and the db field should be BLOB.after uploading the string should be converted back to bitmap and then image(This conversion should be written by api guy).

public String BitMapToString(Bitmap bitmap) {
 ByteArrayOutputStream baos=new  ByteArrayOutputStream();
 bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
 byte [] b=baos.toByteArray();
 String temp=Base64.encodeToString(b, Base64.DEFAULT);
 return temp;
}
Harish Reddy
  • 922
  • 10
  • 20