0

I write app on android which will need to exchange xml data with http server. I wonder what would be the better approach. Send whole file via POST or maybe get all text from file put it on String and then send this String via POST. Is there will be some difference? If yes what is better option?

AYMADA
  • 889
  • 3
  • 17
  • 37
  • 1
    Take a look at this : http://stackoverflow.com/questions/4126625/how-to-send-a-file-in-android-from-mobile-to-server-using-http?rq=1 – Romin Jul 13 '12 at 08:09

1 Answers1

1

I would strongly recommend using POST. While sending the file content using GET is theoretically possibly, in some cases you may encounter problems when using URLs over 2000 characters in length. RFC imposes no strict limit, however some clients and servers impose their own limit. Look at this question for more details on this.

With POST this wouldn't apply and you can send (almost) any size data. To send the file, you would still need to read the content of the file and send it as POST parameter though. Again, in reality, most servers will not accept more than just below 2GB, but that's a separate issue.

Community
  • 1
  • 1
Aleks G
  • 56,435
  • 29
  • 168
  • 265