Android: Sending a byte[] array via Http POST

前端 未结 3 1156
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 06:07

I am able to do a POST of a parameters string. I use the following code:

String parameters = \"firstname=john&lastname=doe\";
URL url = new URL(\"http://         


        
相关标签:
3条回答
  • 2020-12-03 06:19

    These links might be helpful:

    • Android httpclient file upload data corruption and timeout issues
    • http://getablogger.blogspot.com/2008/01/android-how-to-post-file-to-php-server.html
    • http://forum.springsource.org/showthread.php?108546-How-do-I-post-a-byte-array
    0 讨论(0)
  • 2020-12-03 06:19

    Take a look here Sending POST data in Android

    But use ByteArrayEntity.

    byte[] content = ...
    HttpPost httpPost = new HttpPost(url);
    httpPost.setEntity(new ByteArrayEntity(content));           
    HttpResponse response = httpClient.execute(httpPost);
    
    0 讨论(0)
  • 2020-12-03 06:31

    You could base-64 encode your data first. Take a look at the aptly named Base64 class.

    0 讨论(0)
提交回复
热议问题