Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All

From my android app,I need to send Media(video,image) to a web server having WCF services deployed to save the image on the server end. The request and response type is JSON for the web methods...

The issue is that in the app, when i convert image to byte array and then to base64 string, the length of the encoded string becomes significantly large...
<br />
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ.....and so-on 


for a relatively small image too of just 16 Kb

Is there a cleaner way to do this rather than sending large encoded base 64 string on the server side and then again decoding it to get the image/video??

Thanks :)
Posted
Updated 24-Feb-15 8:22am
v5
Comments
Sergey Alexandrovich Kryukov 24-Feb-15 14:22pm    
This is easy, but the question is: why?
—SA
[no name] 24-Feb-15 14:28pm    
Hey
The question is "what are other way around to do the same thing i.e sending the image/video to the web-server from an app"
actually base64 is a significantly large string and i need some other better way if any...

1 solution

Converting data to base64 is supposed to make considerably larger chunk of data. (What else would you possibly expect?) It just makes no sense except the cases when it is done to use some transport which requires only 8-bit or 7-bit text data. One example is sending data in e-mail the way independent from the content type (charset part of it) of the mail message itself.

To learn data transfer using WCF, you can start here: https://msdn.microsoft.com/en-us/library/ee473426%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2
Comments
[no name] 25-Feb-15 3:10am    
Thanks, My client application is in Android not .net. I have to save image/video from phone using app and then posting the media to the host service (request format JSON ) where i save it in hosting server and then show in app via its url.
I didn't take that route at first because I was not sure if video could be encoded in Base64. But I just looked it up briefly and it seems that it is possible but have to send a long base 64string

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900