Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I'm writing a console application that uploads large files to dropbox. I want my program to resume failed upload whenever it accidentally exits or drops connection. I retrive the uploadID and offset from a txt file to achieve this.
But I constantly get "A task was canceled" issue. And I figured it is a timeout error. I have set "Timeout = TimeSpan.FromMinutes(30)" but it isn't working.
So how can I fix this?
Below is my code:
try
{
var httpClient = new HttpClient(new WebRequestHandler { ReadWriteTimeout = 10 * 1000 })
{
// Specify request level timeout which decides maximum time that can be spent on
// download/upload files.
Timeout = TimeSpan.FromMinutes(30)
};
var response = await _client.Core.Metadata.ChunkedUploadAsync(fragmentBuffer, count, uploadId, currentPosition, asTeamMember, cancellationToken).ConfigureAwait(false);
Console.Write("\r\n2try: {0} of {1} uploaded. uploadId: {2}\r\n", currentPosition, _dataSource.Length, uploadId);
uploadId = response.upload_id;
var testoffset = response.offset;
uploadoffset = testoffset;
var testexpires = response.expires;
currentPosition = endPosition;
Console.Write("\r\n3currentPosition: {0} endPosition: {1} testexpires: {2} count: {3} \r\n", currentPosition, endPosition, testexpires, count);
}
//catch (TaskCanceledException ex)
//{
// // Check ex.CancellationToken.IsCancellationRequested here.
// // If false, it's pretty safe to assume it was a timeout.
// Console.WriteLine("\r\nerr TaskCanceledException: {0}\r\n", ex.CancellationToken.ToString());
//}
catch (Exception e)
{
//write down offset and uploadID to a txt
StreamWriter sw = new StreamWriter("1.txt");
sw.WriteLine(uploadoffset.ToString());
sw.WriteLine(uploadId.ToString());
sw.Close();
Console.WriteLine("7Err getting response:{0} .. Make sure you have connection again then press enter to resume. \n", e.Message);
Console.Write("7catch: currentPosition: {0} endPosition: {1} \r\n", currentPosition, endPosition);
Console.ReadLine();
}
Based on your code, it looks like you're using this third party DropboxRestAPI library. Is that correct? If so, unfortunately I'm afraid I can't be of much help, as we can't support third party libraries themselves.
Also, it appears that one uses API v1, which is deprecated. You should migrate to API v2. We have an official API v2 .NET SDK that we recommend using. It has an example for uploading large files that you can refer to.
Based on your code, it looks like you're using this third party DropboxRestAPI library. Is that correct? If so, unfortunately I'm afraid I can't be of much help, as we can't support third party libraries themselves.
Also, it appears that one uses API v1, which is deprecated. You should migrate to API v2. We have an official API v2 .NET SDK that we recommend using. It has an example for uploading large files that you can refer to.
Thank you, I will check out the new API to see how it works. Thanks!
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on Twitter or Facebook.
For more info on available support options, see this article.
If you found the answer to your question, please 'like' the post to say thanks to the user!