Search code examples
javaandroidhttpdropboxhttpconnection

Downloading from dropbox url ignores range


If i want to download a file from a dropbox url my http header range is ignored:

httpRequest = new HttpGet(url.toURI());
httpRequest.addHeader("Range", "bytes=" + startPos + "-"    + dwnInfo.getStopRange());
httpRequest.addHeader("Accept-Encoding", "");

So instead of making my file download in x chunks of 5mb for ex, the connection ignores the specified range and it downloads x chunks of Y mb, where y is the full size of the file.

Downloading from an amazon storange link i don't have any problems.

Anyone else encountered this situation ? This only happens from some days ago. This wasn't a issue until now.

I tried to look on dropbox dev page but didn't see anything that specifies if they removed the accepted range on urls


Solution

  • The link you gave is to an HTML page (total size ~46KB), so even if range retrieval worked there, it wouldn't be very useful.

    Per https://www.dropbox.com/help/201/en, you can turn a share link into a direct link to the file by changing the domain to dl.dropboxusercontent.com, so your link becomes https://dl.dropboxusercontent.com/s/5c7atlfmacjf3qn/02%20Armin%20Van%20Buuren%20-%20A%20State%20Of%20Trance%20Year%20Mix%202013%20%28Cd%202%29.mp3, and range retrieval works for that URL.

    (Here I'm using 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