Send image via json in android - android

Hi I am working with android.I want to send an image from server to android and I had done it with sending url from server.How can I send an image from server to android app via json?? is it possible??

It is possible if you can convert your image at your server to a Base64 encoding string. Then you can send the string to your app via JSON.
You can use Apache Common IOUtils:
Base64.encode(FileUtils.readFileToByteArray(imageFile));
On your app you can convert the string to image, example in this link
How to convert a Base64 string into a BitMap image to show it in a ImageView?
Hope that helps

It is possible to send binary data within Json but you have to escape the binary data (UTF-8 encoding and use Base64.) This will increase the data size. Why not just include the path in JSON and fetch/load it?

Related

How to upload a photo to a webservice using Xamarin Forms

I am trying to upload a photo to my data base using Xamarin forms. I have the image. How would I use HTTP Post to push it up to the web service?
Thanks
First: write code to covert your image to base64 string.
Second: Pass this string to your web service using HTTP Post.
third: in your web service write code to convert this base64 string to image.
fourth: store that image in your server directory

wanted to post image from android to WCF rest service

I want to upload or post a image file on server using REST WCF. For this I am using JSON as input format.
But when I am checking this post call with debugger due to Base64 image data input is not accepted by the debugger .
I was giving me the 400-Bad Request response for this call.
Thanks.
First understand the concept of JSON/REST.
Then Make your WCF method to input the Byte[] i.e. Byte Array.
Convert your Image in Base64 and Pass it to the REST.
In order to send Image to JSON Web Service, you need to convert that to Byte Array or Base 64 String Representation.
Hope this helps.

Android to .NET image transfer using HTTP Get

I have successfully send a string from android to .NET using HTTP GET, I am using WCF in the .NET end, my real intention is to send an image from android mobile to .NET server, can I use GET for this, ie, convert the image into base64 string and then send the image to .NET just like I did for the string? If no, why is it not possible?
GET would append the Base64 encoded string representation of the image to the URL. URLs have length limitations hence the entire string may not get transferred.
A better approach would be to use POST with JSON data to hold the Base64 encoded image string.

Image Upload Using .net Webservices

I am Developing an Android Based Application. I am Using .net webservice to upload the data. Here I am successfully able to upload all the data except Image Byes. I want to know how to send Image as Binary array to the .net webservice.
I think you can convert images in the Base64 string and then its easy to upload string on the server.
Just check this question for code of Converting image to Base64 string

How to upload image from Android device to Rails server?

I am working on a Android project and want to upload Bitmap images to my rails server. But I have no idea how to write the Rails models or controllers.
I find someone using MultipartEntity post to upload images and paperclip to recieve images on RoR server. I want to know how to connect the post and server (what url?) and how to write the model or controller.
I use a stupid method. I convert the Bitmap image to byte array and use Base64 method to convert it to a string. Post the string to server. When I want to get image, download the string and convert it to Bitmap.

Categories

Resources