在android上通过POST发送二进制数据

5 client android http

Android支持apache的http客户端(v4)的限制版本.通常,如果我想通过POST使用content type = application/octet-stream发送二进制数据,我会执行以下操作:

              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);

但Android上不支持ByteArrayRequestEntity.我能做什么?

Mat*_*hen 5

我想你想要的ByteArrayEntity. ByteArrayRequestEntity来自3.x.