0

I'm currently developing an android application that takes in a file and converts it into a string. The string is then sent over to a server and I'm using a MVC application in this case. The string has to be sent to a server first because I needed to do some processing before storing it. Below is my code for the MVC application.

[HttpPost]
        public HttpResponseMessage RetrieveFile(String fileString)
        {
            var response = new HttpResponseMessage()
            {
                Content = new StringContent("{\"File\":\"" + fileString + "\"}")
            };
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return response;
        }

However, whenever I call the http://localhost/api/TestCon/RetrieveFile?fileString=*Very Long String* . it throws a "Request URL Too Long" error message. What do I have to do to send a large about of data, possibly a few MBs, over to the server?

radar
  • 13,270
  • 2
  • 25
  • 33
SpencerRoi
  • 91
  • 1
  • 1
  • 7
  • Have you considered sending the file as an attachment with POST request? You can compress the file and decompress it in your server. Sending a long string over the wire without compression may not work well on slow network connections. Take a look at this link for some hints - http://stackoverflow.com/questions/13002547/android-httppost-with-parameters-and-file – indyfromoz Nov 18 '14 at 02:55
  • Thanks for your reply! From what I understand from the link, this sample allows users to send their data over to the server. What if I need to access the files again? How do I reconstruct the file and send it back to the android device? How does the Server receives the file too? – SpencerRoi Nov 18 '14 at 04:51

0 Answers0