Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunky download #87

Open
i1yxa opened this issue Oct 4, 2018 · 6 comments
Open

Chunky download #87

i1yxa opened this issue Oct 4, 2018 · 6 comments

Comments

@i1yxa
Copy link

i1yxa commented Oct 4, 2018

Hi!
I've downloading large files. Connection bandwidth is low. I want to implement download recovery after disconnect and continue download.
Unfortunetly, I've not found how I can specify offset and size part of requested file review.
Can you help me to do it?

@greg-db
Copy link
Contributor

greg-db commented Oct 4, 2018

The API v2 /2/files/download HTTPS endpoint itself does support "Range Retrieval Requests", but that's unfortunately not currently implemented in the Dropbox .NET SDK. I'll send this along as a feature request for that, but I can't promise if/when that would be implemented in the SDK.

That being the case, you could implement the HTTPS call directly, outside of the SDK, so you can set the desired Range header.

@i1yxa
Copy link
Author

i1yxa commented Oct 5, 2018

Hi!
Just add the code and it will work:

var uri = "https://content.dropboxapi.com/2/files/download";
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.Headers.Add("Authorization", $"Bearer {_generalCfg.AccessToken}");
request.Headers.Add("Dropbox-API-Arg", $"{{\"path\": \"{_msg.Request.File}\"}}");
request.AddRange(_from, _to);

@i1yxa
Copy link
Author

i1yxa commented Oct 5, 2018

Better way

                  var uri = "https://content.dropboxapi.com/2/files/download";
                  var request = new HttpRequestMessage(HttpMethod.Post, uri);
                  request.Headers.Authorization = new AuthenticationHeaderValue("Bearer",AccessToken);
                  var encodedPath = EncodeNonAsciiCharacters(file.Path); 
                  var args = $"{{\"path\": \"{encodedPath}\"}}";
                  request.Headers.Add("Dropbox-API-Arg", args);
                 
                  request.Headers.Range =
                  new RangeHeaderValue(_msg.Request.Offset, _msg.Request.Offset + _msg.Request.Length - 1);

                  var response = await httpClient.SendAsync(request, 
                     HttpCompletionOption.ResponseHeadersRead)
                     .ConfigureAwait(false);
                  response.EnsureSuccessStatusCode();

@mcdis
Copy link

mcdis commented Nov 14, 2018

Any progress?

@risforrob
Copy link

Hey all, there is no update on this issue to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@risforrob @greg-db @mcdis @i1yxa and others