首页 文章

OneDrive REST API - 上传 - 转换为jpeg的.png文件的内容

提问于
浏览
0

使用OneDrive REST API上传文件时,扩展名为.png的某些文件的内容会自动转换为JPEG . 我可以使用两种文档化的上传方法重现问题 .
示例png文件:
http://www39.zippyshare.com/v/59255310/file.html
http://www2.zippyshare.com/v/11270772/file.html

供参考的缩短请求:

PUT method

PUT https://apis.live.net/v5.0/folder.<removed>/files/i2.png HTTP/1.1
Pragma: no-cache
<removed - no Content-Type header>
Content-Length: 33579
Host: apis.live.net

当PUT请求标头中的Content-Type设置为application / octet-stream时,将返回以下错误:

HTTP/1.1 415 Unsupported Media Type
Server: Live-API/19.7.925.4009 Microsoft-HTTPAPI/2.0
<removed>

{
   "error": {
      "code": "request_body_invalid_media_type", 
      "message": "The Content-Type header 'application/octet-stream' isn't supported."
   }
}

POST method

POST https://apis.live.net/v5.0/folder.<removed>/files HTTP/1.1
Content-Type: multipart/form-data; boundary=735b1931-a2bb-4970-8142-373848528fcb
<removed>
Content-Length: 33767
Host: apis.live.net

--735b1931-a2bb-4970-8142-373848528fcb
Content-Disposition: form-data; name="file"; filename="i2.png"
Content-Type: application/octet-stream

.PNG<removed>
--735b1931-a2bb-4970-8142-373848528fcb--

Other OneDrive APIs

Microsoft正在OneDrive网站和Windows桌面客户端(skydrive.exe)上使用的API(skyapi.onedrive.live.com/API/2)不会发生此问题 .

OneDrive developers:

而不是在PUT请求中返回415错误,是否可以支持设置Content-Type:application / octet-stream标头的请求?在这种情况下,数据应保持原样,不进行任何数据转换 . 谢谢 .

1 回答

相关问题