Java-从Dropbox网址下载会忽略范围
作者:互联网
如果我想从Dropbox网址下载文件,则会忽略我的http标头范围:
httpRequest = new HttpGet(url.toURI());
httpRequest.addHeader("Range", "bytes=" + startPos + "-" + dwnInfo.getStopRange());
httpRequest.addHeader("Accept-Encoding", "");
因此,该连接不会忽略我的文件,例如不以5mb的x个块下载,而是忽略指定范围,而是下载x个Y mb的块,其中y是文件的完整大小.
从亚马逊存储链接下载,我没有任何问题.
其他人遇到过这种情况吗?这仅在几天前发生.到目前为止,这不是问题.
我尝试查看Dropbox开发人员页面,但没有看到任何指定内容是否删除了网址上可接受的范围的内容
解决方法:
您提供的链接是指向HTML页面的(总大小约为46KB),因此即使在其中进行范围检索也不会很有用.
对于每https://www.dropbox.com/help/201/en,您可以将域更改为dl.dropboxusercontent.com,从而将共享链接转换为文件的直接链接,因此您的链接将变为https://dl.dropboxusercontent.com/s/5c7atlfmacjf3qn/02%20Armin%20Van%20Buuren%20-%20A%20State%20Of%20Trance%20Year%20Mix%202013%20%28Cd%202%29.mp3,并且范围检索适用于该URL.
(这里我使用的是httpie.)
$http get https://dl.dropboxusercontent.com/s/5c7atlfmacjf3qn/02%20Armin%20Van%20Buuren%20-%20A%20State%20Of%20Trance%20Year%20Mix%202013%20%28Cd%202%29.mp3 range:bytes=0-0
HTTP/1.1 206 PARTIAL CONTENT
Connection: keep-alive
Content-Length: 1
Content-Type: audio/mpeg
Date: Wed, 18 Jun 2014 14:53:32 GMT
Server: nginx
accept-ranges: bytes
cache-control: max-age=0
content-range: bytes 0-0/146014047
etag: 346n
pragma: public
set-cookie: uc_session=2cqmevWxG8lmGt743KMXebc23dRC5iuZEfm8Etx6V2VShWk60jmnUJajFnH1wRG4; Domain=dropboxusercontent.com; Path=/; secure; httponly
x-dropbox-request-id: 2f0c5986a62cf2f0b06af1704ece5bd7
x-server-response-time: 535
I
标签:http,dropbox,httpconnection,java,android 来源: https://codeday.me/bug/20191121/2053078.html