title: WordPress REST API: Can't upload content-type image/jpeg
body: <p>The WordPress REST API apparently won't let me upload a file with content-type 'image/jpeg'.</p>
  
  <p>If I set content-type to an empty string, I'm able to create a media item and upload an attached file (which appears in both the media library and the wp_content/uploads directory). Doing this, however, results in an invalid image which WordPress can't process.</p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>def post():
      url = 'https://www.example.com/wp-json/wp/v2/media'
      data = open('C:\\Pictures\\foo.jpg', 'rb').read()
      r = requests.post(url=url,
                      files={'filename1': data},
                      data={'title': 'Files test'},
                      headers={'Content-Type': '', 'Content-Disposition': 'attachment; filename={}'.format('foo.jpg')},
                      auth=('username', 'password'))
      return (r.status_code, r.text)
  </code></pre>
  
  <p>When I set Content-Type to 'image/jpg', 'image/jpeg', 'image', 'multipart', 'application' or 'application/image' (I'm getting desperate) I get a 403. </p>
  
  <p>If I set it to 'application/json' as suggested by others, I get a 400 with 'invalid JSON body passed'. </p>
  
  <p>If I omit Content-Type I get a 500 with the following message:</p>
  
  <pre><code>{"code":"rest_upload_unknown_error","message":"File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.","data": {"status":500}}')
  </code></pre>
  
  <p>My file is not empty (it's 26kB) and the suggested PHP.ini errors presumably can't apply if I am able to upload a file with Content-Type = ''.</p>
  
  <p>Any suggestions, please?</p>