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.
Related
I am trying to send an image from android client to .NET based server, I am doing it using HTTP POST, will there be any significant difference if I use a stream for file upload or send the data as a base64 string, ie convert the string into base64, send and at the server side convert the base64 string back to image, what difference does it make?
There are a few (small) advantages to streaming instead of converting to base64. One is that the conversion to base64 will increase the byte load by about 30% going over the wire. Then there's the extra processing (and programming) involved in the conversion at both ends.
Having said that, I'd recommend base64 over streaming because, in the end, the programming will be much easier I think. Boxing up and sending an HTTP message, even if it contains a boat-load of base64 characters, should be child's play compared to getting that whole stream-send/stream-response business working on Android, right? How hard is it to concatenate into JSON a big string of characters? That's why I'd go with base64.
I want to send a picture from my mobile to my server, and i know how to send it using base64 but i've heard that base64 is not recommended to use because base64 encoding increases the size of image by 37%, which in case slows down the performance of server because there will be too many images shared by users on the server.
can anyone recommend me the efficient technique than base64 encoding for the mobile based image sharing application (client-server app)?
You could simply POST your image (in regular UTF-8 encoding) as explained here: NSData and Uploading Images via POST in iOS. You will need to have some server-side servlet or php page to decode the image and save it.
You can use FTP, for uploading and downloading images from iPhone. The main advantage of using FTP over other methods is that we can set the bytes width per second to certain limit and can detect how much data has been transferred till Particular event.
Here is the code given by apple documentation to illustrate the uploading and downloading of any data (image, pdf, video or audio anything) over FTP.
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFFTPTasks/CFFTPTasks.html#//apple%5Fref/doc/uid/TP30001132-CH9-SW1
Also refer this PDF for better understanding
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFNetwork.pdf
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?
I am sending multiple PDF files through SOAP which will be received by an Android client. But when receiving the SOAP response, it is throwing OutOfMemoryException.
I want to know whether its a limitation of kSOAP or Android. Please guide me how to overcome it.
Thanks.
I would suggest to not do that. Just put the raw url to the pdf file into the soap message and download the pdf separately independent of soap. That works great for me with PDF files as well as images..
So in a bit more detail:
One of your results from the SOAP request should contain a full public url to the PDF file somewhere on the internet.
Then use DownloadManager or whatever you want in terms of Android development to get the file downloaded by using the url you got from the soap response. But dont have the PDF wrapped within the soap request. That way you can also show a progress bar during download and so on nicely. Downloading files on Android is documented everywhere..
I now that this is old question but maybe I help other developers. The most efficient way to sending a large binary content from/to web service is MTOM transfer (SOAP with attachments). The problem is that ksoap2 library doesn't support this feature, but you can try http://easywsdl.com generator. What I know is that it supports MTOM transfer and allows you to send/retrieve very large binary files. Of course MTOM transfer has to be enabled also on the web service side.
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.