Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Andrewer016
6 years agoExplorer | Level 4
[C#] Large files don't show up in user's cloud after finishing batch upload
Hey there!
I'm trying to upload large files with batch upload (as it is suggested by Dropbox: https://www.dropbox.com/developers/reference/data-ingress-guide).
Everything seems to be working exce...
- 6 years ago
I see that you are checking the 'IsComplete' status of the UploadSessionFinishBatchAsync job using UploadSessionFinishBatchCheckAsync, but that will only tell you if the operation is complete overall. It does not indicate whether any particular commit succeeded or not. You should additionally check each UploadSessionFinishBatchResultEntry (in UploadSessionFinishBatchResult.Entries) to see if each one was a Success or a Failure. Additionally, if it failed, you can see why from the UploadSessionFinishError available in UploadSessionFinishBatchResultEntry.Failure.Value.
By the way, I redacted it from your post, but for the sake of security, you should disable that access token, since you posted it here. You can do so by revoking access to the app entirely, if the access token is for your account, here:
https://www.dropbox.com/account/connected_apps
Or, you can disable just this access token using the API:
HTTP: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
API Explorer: https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/revoke
Greg-DB
Dropbox Community Moderator
5 years ago
Q1. Perhaps Andrewer016 would be so kind as to share their updated code with that fixed.
Q2. Likewise, perhaps Andrewer016 can share this piece as well, if they updated their code to include this.
Very basically though, it would look like this:
foreach (var entry in status.AsComplete.Value.Entries)
{
if (entry.IsSuccess)
{
Console.WriteLine(entry.AsSuccess.Value);
} else if (entry.IsFailure)
{
Console.WriteLine(entry.AsFailure.Value);
}
}
You can likewise drill down further into that 'entry.AsFailure.Value' as needed for more specific error information.
Q3. Dropbox doesn't have official guidance or policy on how often you should poll UploadSessionFinishBatchCheckAsync, so that's up to you, but adding a short delay like that does seem reasonable.
dotNET_Guy
5 years agoExplorer | Level 3
Thanks Greg.
After working on this for most of the day, I think I have the solutions. They appear to be working.
1.
The final offset should be at the position of end of the file (i.e. size of the file)
var uploadSessionCursor = new UploadSessionCursor(uploadSessionID, (ulong)fileStream.Length);
await client.Files.UploadSessionAppendV2Async(uploadSessionCursor, true, memoryStream);
But too apply this final offset, you will need an extra iteration in the loop, so alter the for loop and if statement (in the final chunk) appropriately:
for (ulong indexOfChunks = 0; indexOfChunks <= numberOfChunks; indexOfChunks++)
if (indexOfChunks == numberOfChunks)
2. The UploadSessionFinishBatchCheckAsync() method actually returns an object type of UploadSessionFinishBatchJobStatus
var uploadSessionFinishBatchJobStatus = await client.Files.UploadSessionFinishBatchCheckAsync(uploadSessionFinishBatch.AsAsyncJobId.Value);And use your aforementioned code.
If you wanted to simply check if all jobs in the batch committed successfully, I coded it in 1 line of code using Linq:
result = uploadSessionFinishBatchJobStatus.AsComplete.Value.Entries.Select(j => j.IsSuccess).Count() == uploadSessionFinishBatchJobStatus.AsComplete.Value.Entries.Count();
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!