【问题标题】:"Content-type" for uploading jars files using Web HDFS REST client使用 Web HDFS REST 客户端上传 jar 文件的“内容类型”
【发布时间】:2016-02-18 06:55:12
【问题描述】:

我正在使用 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 时遇到问题。上传的文件已损坏。

上传 jars 需要在“Content-type”和“Accept”中设置什么?

【问题讨论】:

    标签: hadoop httpclient apache-httpclient-4.x webhdfs


    【解决方案1】:
    HttpPut httpPut = new HttpPut(urlString);
    httpPut.setEntity(new StringEntity(readFile(fileName)));
    httpPut.setHeader("Accept", "binary/octet-stream");
    httpPut.setHeader("Content-type", "binary/octet-stream");
    

    使用 binary/octet-stream 代替 application/xml

    【讨论】:

      猜你喜欢
      • 2014-11-21
      • 2016-03-26
      • 1970-01-01
      • 2021-07-03
      • 2011-07-19
      • 2021-10-14
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      相关资源
      最近更新 更多