I'm looking for a complete example for uploading an image + some text fields from Android to a WCF service. I've been searching for days without finding any useful examples. What I need is the code for both the client and server.
I've been able to make it work with JSON and Base64 encoding the image as a string, but this is way too slow with images around 500KB. What I'm looking for has to be efficient. Probably using a stream.
Can anyone please give me a complete sample code? I've seen a lot of snippets on each side, but not a complete sample. From getting the image from a path on the phone to posting it to the server and consuming it on the server in C#? How to get the image as a bytearray on the server and the text into string variables?
Thanks for listening.
For setting up WCF streaming on the server side see : http://msdn.microsoft.com/en-us/library/ms789010.aspx
You could also try just using basic http binding and MTOM.
For the android part you will need to get help from someone else, sorry.
Related
Earlier I was using base64 string for image encoding and sending to node.js server by using socket.io . But after referring some questions I came to know that base64 format is inefficient as it increases the image size by 33% . So, is there any way to transmit data through socket.io by multipart/form-data or something like that.
Actually I'm a beginner in this multipart/form-data concept so please do excuse me if my question is foolish.
I would rather use Firebase or Retrofit for multipart image uploading to server.
I am able to parse html content using HTMLCleaner & able to populate in list view. But extracting image I ma facing problem. while I am able to get images from any web server, i am not able to get same from my local Apache http server.
I want to know the reason & possible solution.
Thanks in advance.
It seems like the phone (emulator?) doesn't have access to your local server.
Use the browser in the phone/emulator and try to access your server just to make sure if it's this problem.
If you have access, print the url and make sure everything is alright.
I have an android application, that will call a SOAP web service for some data.
For the purpose of this question, we'll assume its data about cars.
I've got as far as returning text data about the car (make, model etc), that is the easy part. I'd also like to return an image of the car some how.
So far, I see two viable options :
Retrieve the image in the SOAP response (don't even know if this is
possible)
Retrieve a URL in the SOAP response that points to the image,
perhaps a URL to a web image
Could anyone please give advice as to what is a robust solution for achieving this?
Thanks
Option 2, definitely. If you do option 1, you're limited to displaying only after you've completely downloaded the entire message, including the encoded images. That can take a while. On the other hand, if you just include URLs, you can download the message, render your UI, then download the images and update those image views dynamically as the images finish fetching from the web. This results in a much more responsive UI, especially in a mobile environment where your data connection may not be as fast or reliable.
I searched many links but not able to find the solutions. As i dont have much idea about coding Asp.net . Can any one help me about the procedure with example to upload a image from the imageview to the Asp.net server.
thanks in advance
I used the same way as in JME.check this. Uploading images is done through HTTP post and
multipart/form-data content type which is accepted by all server side languages, so it should work in ASP.NET in the same was as it works in PHP.
I am currently getting a base64 encoded image from a mobile device's camera using PhoneGap, I would like to upload the image to a server to then store. Not sure what the right approach is?
As expected, if I try to include the base64 string as a parameter I get the Error 414 (Request-URI Too Large)
Even if you use POST the server accepting the POST will need to be capable of decoding the base64 parameter. Luckily the PhoneGap API provides a better way to do this with FileTransfer.
You need to get the file handle to the image instead of the base64 encoding. Using the file handle resolves the issue of getting a JavaScript out of memory error. This also removes any cross-site scripting issues since PhoneGap is using native code to perform the post instead of using the browser. Hope that helps.
I agree with Chuck you are better off using the FileTransfer object. Large Base64 strings will cause out of memory errors in your app. Zac has a good tutorial on the subject:
http://zacvineyard.com/blog/2011/03/25/upload-a-file-to-a-remote-server-with-phonegap/
Why not use HTTP POST instead of HTTP GET?