首页 文章

OneDrive API部分下载

提问于
浏览
0

我目前正在尝试开发基于Java的应用程序来访问OneDrive .

今天我试着按照这里描述的那样实现下载:https://dev.onedrive.com/items/download.htm

我想使用range参数,为用户提供暂停大量下载的功能 . 但无论我如何将参数发送到HTTP-Request标头或URL作为GET参数,它总是会发送给我完整的文件 .

到目前为止我尝试的事情:

  • https:/ /api.onedrive.com/v1.0/drive/items/***/content?range=0-8388607

(OAuth通过HTTP标头)

  • https:/ /api.onedrive.com/v1.0/drive/items/***/content:

Headers :授权:***

范围:0-8388607

  • https:/ /api.onedrive.com/v1.0/drive/items/***/content:

Headers :授权:***

range:bytes = 0-8388607

我还尝试了内容范围和大小写的各种变化而没有成功 . 这个剂量不起作用的任何原因?

PS:

由于我使用的新帐户每个帖子只允许2个链接,因此链接损坏了,我知道这是两个//之间的空格//在我的帖子中;)

1 回答

  • 2

    请求支持文件范围 . 您可能希望使用fiddler或其他工具来查看执行302重定向后是否正在传递原始标头 . 下面是我提供在302重定向发生后传递的范围标头时的HTTP请求和响应 . 您会注意到返回了HTTP 206部分内容响应 . 此外,要恢复下载,您可以使用“范围:字节= 1025-”或接收的最后一个字节 . 我希望有所帮助 .

    GET https://api.onedrive.com/v1.0/drive/items/item-id/content HTTP/1.1 Authorization: Bearer Range: bytes=0-1024 Host: api.onedrive.com

    HTTP/1.1 302 Found Content-Length: 0 Location: https://kplnyq.dm2302.livefilestore.com/edited_location Other headers removed

    GET https://kplnyq.dm2302.livefilestore.com/edited_location Range: bytes=0-1024 Host: kplnyq.dm2302.livefilestore.com HTTP/1.1 206 Partial Content Cache-Control: public Content-Length: 1025 Content-Type: audio/mpeg Content-Location: https://kplnyq.dm2302.livefilestore.com/edited_location Content-Range: bytes 0-1024/4842585 Expires: Tue, 11 Aug 2015 21:34:52 GMT Last-Modified: Mon, 12 Dec 2011 21:33:41 GMT Accept-Ranges: bytes Server: Microsoft-HTTPAPI/2.0 Other headers removed

相关问题