dropbox-sdk-dotnet
dropbox-sdk-dotnet copied to clipboard
Chunky download
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?
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.
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);
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();
Any progress?
Hey all, there is no update on this issue to date.