title: HTTP Error 415 Unsupported media type
body: <p>I am still on the same problem as:
  <a href="https://stackoverflow.com/questions/33956085/upload-binary-data-with-http-put-with-jersey-jaxrs-ri-2-01/33957438?noredirect=1#comment55676414_33957438" title="Upload binary data with HTTP PUT with jersey jaxrs-ri-2.01">Upload binary data with HTTP PUT with jersey jaxrs-ri-2.01</a></p>
  
  <p>But I am one step further. Now I am testing my data upload with this tool:
  <a href="http://www.swensensoftware.com/im-only-resting" rel="nofollow noreferrer">I'm Only Resting</a></p>
  
  <p>The problem, and I don't know if it's a client or a server problem is that when I'm testing, I get <strong>HTTP 415 - Unsupported Media Type</strong></p>
  
  <p>In the client:</p>
  
  <ul>
  <li>I have checked the <strong>PUT</strong> method</li>
  <li>In the body I have put <strong>one blank line (return)</strong> and in the second line i wrote <strong>test</strong></li>
  </ul>
  
  <p>In the server, It was working until I added this parameter</p>
  
  <pre><code> @FormDataParam("file") InputStream pBodyDataStream
  </code></pre>
  
  <p>and this code:</p>
  
  <pre><code>    try {
          OutputStream lOutputStream = new FileOutputStream(new File("F:/test.bin"));
  
          int read = 0;
  
          byte[] bytes = new byte[fragmentSize];
  
          while ((read = pBodyDataStream.read(bytes)) != -1) {
              lOutputStream.write(bytes, 0, read);
          }
  
          lOutputStream.close();
          pBodyDataStream.close();
      } catch (IOException e) {
          // fragment reception error
  
          // HTTP 500 error
          lOutput = xmlError("Upload error while transferring fragment");
          e.printStackTrace();
          return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(lOutput).build();
      }
  </code></pre>
  
  <p>Here is a screenshot of the test tool with the parameters:</p>
  
  <p><a href="https://i.stack.imgur.com/ot8Mh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ot8Mh.png" alt="Screenshot 1"></a></p>
  
  <p><strong>Here is the cURL investigation:</strong></p>
  
  <p>The command line:</p>
  
  <pre><code>curl -v -H "application/octet-stream" -K params_curl.txt
  </code></pre>
  
  <p>The cURL parameters file:</p>
  
  <pre><code>url = "localhost:8080/ServeurWS/softplus/biens/arts/2345412/images?user=wow&amp;pass=wow&amp;taille=100&amp;numfrag=1&amp;taillefrag=10&amp;md5=d6aa97d33d459ea3670056e737c99a3d&amp;md6=5da8aa7126701c9840f99f8e9fa54976"
  request="PUT"
  upload-file="f:/vcredist.bmp"
  output = "output.html"
  user-agent = "superagent/1.0"
  </code></pre>
  
  <p>The headers I see, thanks to the <strong>-v</strong> option:</p>
  
  <pre><code>C:\Users\Dev\Desktop&gt;curl -v -I -H "application/octet-stream" -K params_curl.txt
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ::1...
  * Connected to localhost (::1) port 8080 (#0)
  &gt; PUT /ServeurWS/softplus/biens/arts/2345412/images?user=wow&amp;pass=wow&amp;taille=100&amp;numfrag=1&amp;taillefrag=10&amp;md5=d6aa97d33d459ea3670056e737c99a3d&amp;md6=5da8aa7126701
  c9840f99f8e9fa54976 HTTP/1.1
  &gt; Host: localhost:8080
  &gt; User-Agent: superagent/1.0
  &gt; Accept: */*
  &gt; Content-Length: 5686
  &gt; Expect: 100-continue
  &gt;
  &lt; HTTP/1.1 100 Continue
  } [5686 bytes data]
  * We are completely uploaded and fine
  &lt; HTTP/1.1 415 Type de Support Non Supporté
  &lt; Server: Apache-Coyote/1.1
  &lt; Content-Type: text/html;charset=utf-8
  &lt; Content-Length: 1108
  &lt; Date: Wed, 02 Dec 2015 13:56:07 GMT
  &lt;
  { [1108 bytes data]
  100  6794  100  1108  100  5686  11080  56860 --:--:-- --:--:-- --:--:-- 63177
  * Connection #0 to host localhost left intact
  </code></pre>
  
  <p>The <strong>output.html</strong> file:</p>
  
  <pre><code>HTTP/1.1 100 Continue
  
  HTTP/1.1 415 Type de Support Non Supporté
  Server: Apache-Coyote/1.1
  Content-Type: text/html;charset=utf-8
  Content-Length: 1108
  Date: Wed, 02 Dec 2015 13:56:07 GMT
  
  &lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/6.0.44 - Rapport d'erreur&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;Etat HTTP 415 - Unsupported Media Type&lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Rapport d'Ã©tat&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Unsupported Media Type&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;Le serveur a refusÃ© cette requÃªte car l'entitÃ© de requÃªte est dans un format non supportÃ© par la ressource demandÃ©e avec la mÃ©thode spÃ©cifiÃ©e.&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.44&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>And there is no error in the Eclipse console...</p>