Hadoop &引用;“内容类型”;用于使用Web HDFS REST客户端上载jars文件

Hadoop &引用;“内容类型”;用于使用Web HDFS REST客户端上载jars文件,hadoop,httpclient,apache-httpclient-4.x,webhdfs,Hadoop,Httpclient,Apache Httpclient 4.x,Webhdfs,我使用的是Web HDFS REST客户端,我能够上传.xml和.q文件 代码的有用部分- CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPut httpPut = new HttpPut(urlString); httpPut.setHeader("Accept", "application/xml"); httpPut.setHeader("Content-type", "application/xml")

我使用的是Web HDFS REST客户端,我能够上传
.xml
.q
文件

代码的有用部分-

CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPut httpPut = new HttpPut(urlString);
httpPut.setHeader("Accept", "application/xml");
httpPut.setHeader("Content-type", "application/xml");
CloseableHttpResponse response = httpclient.execute(httpPut);
我在上传
.jar
时遇到问题。上载的文件已损坏

我应该在“内容类型”和“接受”中设置什么来上传JAR

HttpPut httpPut = new HttpPut(urlString);
httpPut.setEntity(new StringEntity(readFile(fileName)));
httpPut.setHeader("Accept", "binary/octet-stream");
httpPut.setHeader("Content-type", "binary/octet-stream");
使用
二进制/八位字节流
而不是
应用程序/xml