You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Engg
2 years agoExplorer | Level 3
System.Threading.Tasks.TaskCanceledException: A task was canceled.
We have 500 machine which upload file at same time. We are getting RateLimitException. We are doing a retry after waiting rateLimitException.ErrorResponse.RetryAfter seconds. to test this. I came ...
- 2 years ago
In general modifying the folder should not affect probability for exception appearing, but cannot prevent it. Some decrement may happen if different files/folders appear in different namespaces (namespaces are locked independently, so less likely compete), but better don't rely on.
Again, try to schedule the uploads in non overlap way and handle the possible exception in proper way. Example of such exception handling (again just example and far from optimal) follows:
private readonly int retryLimit = 20; ... var backoff = 0; var rand = new Random(); var commitInfo = new CommitInfo(filePath.Substring(filePath.LastIndexOf('/')), WriteMode.Overwrite.Instance, false); for (var i = 0; i < retryLimit && !string.IsNullOrEmpty(sessionId); ++i) { if (backoff != 0) { Console.WriteLine("Ограничение при завършване на файл {0}. Нов опит след {1} милисекунди...", commitInfo.Path, backoff); Thread.Sleep(backoff); } lastCursor = new UploadSessionCursor(sessionId, (ulong)fileStream.Length); memStream = new MemoryStream(buffer, 0, 0); try { await dbx.Files.UploadSessionFinishAsync(lastCursor, commitInfo, body: memStream); sessionId = string.Empty; } catch (RateLimitException rateLimit) { backoff = (int)(backoff * 1.1); backoff = Math.Max(backoff, rateLimit.RetryAfter * 1000); backoff = Math.Max(backoff, 1000); backoff += rand.Next(500); } } if (string.IsNullOrEmpty(sessionId)) { Console.WriteLine("Качването на {0} приключи \ud83d\ude09.", commitInfo.Path); } else { Console.WriteLine("Неуспешно завършване на файл {0} след {1} опита \ud83d\ude15!", commitInfo.Path, retryLimit); }
The above just shows how my advices (from previous page) can be implemented. Here sessionId represents a session ready for finishing (i.e. content uploaded already).
Engg
Explorer | Level 3
Hey Здравко ,
Thank you for sharing the code to upload large files. I appreciate your help.
I've been utilizing the provided code for uploading large files, and it's been working smoothly. However, I have a question regarding potential exceptions.
Suppose I attempt to upload files with the same parent folder but different subfolders,
like the structure below:
machine1
- testfolder/machine1
machine2
- testfolder/machine2
This pattern extends to 500 machines.
Could modifying the subfolder of the same parent folder lead to exceptions, specifically something like Dropbox.Api.RateLimitException: too_many_requests/...?
Note : These uploads are initiated concurrently from different machine.
Your insights would be greatly appreciated.
Здравко
2 years agoLegendary | Level 20
In general modifying the folder should not affect probability for exception appearing, but cannot prevent it. Some decrement may happen if different files/folders appear in different namespaces (namespaces are locked independently, so less likely compete), but better don't rely on.
Again, try to schedule the uploads in non overlap way and handle the possible exception in proper way. Example of such exception handling (again just example and far from optimal) follows:
private readonly int retryLimit = 20;
...
var backoff = 0;
var rand = new Random();
var commitInfo = new CommitInfo(filePath.Substring(filePath.LastIndexOf('/')),
WriteMode.Overwrite.Instance, false);
for (var i = 0; i < retryLimit && !string.IsNullOrEmpty(sessionId); ++i)
{
if (backoff != 0)
{
Console.WriteLine("Ограничение при завършване на файл {0}. Нов опит след {1} милисекунди...",
commitInfo.Path, backoff);
Thread.Sleep(backoff);
}
lastCursor = new UploadSessionCursor(sessionId, (ulong)fileStream.Length);
memStream = new MemoryStream(buffer, 0, 0);
try
{
await dbx.Files.UploadSessionFinishAsync(lastCursor, commitInfo, body: memStream);
sessionId = string.Empty;
}
catch (RateLimitException rateLimit)
{
backoff = (int)(backoff * 1.1);
backoff = Math.Max(backoff, rateLimit.RetryAfter * 1000);
backoff = Math.Max(backoff, 1000);
backoff += rand.Next(500);
}
}
if (string.IsNullOrEmpty(sessionId))
{
Console.WriteLine("Качването на {0} приключи \ud83d\ude09.", commitInfo.Path);
}
else
{
Console.WriteLine("Неуспешно завършване на файл {0} след {1} опита \ud83d\ude15!",
commitInfo.Path, retryLimit);
}
The above just shows how my advices (from previous page) can be implemented. Here sessionId represents a session ready for finishing (i.e. content uploaded already).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 16 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!