本文介绍了通过POST在Android上发送二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Android支持Apache的HTTP客户端(V4)的限定版。通常,如果我想通过POST使用二进制数据的内容类型=应用程序/八位字节流发送,我做到以下几点:
Android supports a limited version of apache's http client(v4).typically if I want to send binary data using content type= application/octet-stream via POST,I do the following:
HttpClient client = getHttpClient();
HttpPost method=new HttpPost("http://192.168.0.1:8080/xxx");
System.err.println("send to server "+s);
if(compression){
byte[]compressed =compress(s);
RequestEntity entity = new ByteArrayRequestEntity(compressed);
method.setEntity(entity);
}
HttpResponse resp=client.execute(method);
不过ByteArrayRequestEntity不支持Android上。我该怎么办?
however ByteArrayRequestEntity is not supported on android. what can I do?
推荐答案
我想你想<$c$c>ByteArrayEntity$c$c>. <$c$c>ByteArrayRequestEntity$c$c>从3.X
I think you want ByteArrayEntity
. ByteArrayRequestEntity
is from 3.x
这篇关于通过POST在Android上发送二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!