We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Keith B.7
10 years agoHelpful | Level 7
-uploadSessionStartUrl: example?
Apologies for the barrage of questions - it's only because I'm updating a large class to use API 2. Is there an example of how to use -uploadSessionStartUrl: anywhere? (A Google search brings up ...
Greg-DB
Dropbox Community Moderator
10 years agoYes, in that case you would end up sending an empty chunk, but that won't make any difference in the resulting file.
And yes, using the finish batch method is the best way to commit multiple files at the same time without causing lock contention with yourself.
And that's correct, the strategy you described is reccomended for when you need to upload multiple files at once.
Q3. The finish batch endpoint uses a single lock for all of the files to be committed for that call, so you shouldn't run in to (self-)lock contention there. Let us know if you do run in to any issues though of course.
Q4. The finish batch check method is for checking the status of the finish batch job.
Q5. The finish batch method will return a job ID for use with the finish batch check method. The finish batch check method will return the metadata when the job is complete.
Q6. No, unfortunately we don't have a batch download. We'll consider it a feature request though.
Q7. Once the job is done, the batch check method returns a list of results, one per file, each of which will either be success (with the file metadata) or a failure (with the reason for the failure).
Keith B.7
10 years agoHelpful | Level 7
Great, thank you. Okay, so from your answer, I've tracked through the various classes again and mostly got there. So:
1. Once -uploadSessionBatchFinish: completes, its response callback gives you aDBASYNCLaunchEmptyResult object.
2. You can use the .asyncJobId of that empty result object to invoke -uploadSessionBatchFinishCheck:
3. -uploadSessionBatchFinishCheck:'s response callback gives you a DBFILESUploadSessionFinishBatchJobStatus object.
4. You can use the .isComplete property to check the job is finished (or .isInProgress to check it's still in progres).
5. *IF* it is complete, you can call .compete on the job status object to get a UploadSessionFinishBatchResult object.
6. The batch result object has an .entries array. You can then iterate through that to get a DBFILESUploadSessionFinishBatchResultEntry for each upload.
7. For each result entry you check .isSuccess or .isFailure. If .isSuccess, the .success property gives you your meta-data object; if .isFailure, the .failure object gives you the upload error for that file.
Phew! That took a bit of following the chain in the headers.
So, now, only a couple of things elude me:
1. Is there any notification for when the job status changes from .isInProgress to .isComplete? If I call -uploadSessionBatchFinishCheck: from inside the -uploadSessionBatchFinish: response call back, the status is always .isInProgress. So how do I get access to it when it is complete? Am I just supposed to poll every, say, 0.2 seconds or so to check the status? Or is there some way of polling or receiving notifications built into the frameworks?
2. What if the aDBASYNCLaunchEmptyResult object returns .isComplete? In that case, there's no way of getting the .asyncJobId, so I can't call -uploadSessionBatchFinishCheck:, so how do I get the meta-data results in that case?
Many, many thanks for all your patient and informative answers to my many, many questions, by the way!
Thanks and all the best,
Keith
- Greg-DB10 years ago
Dropbox Community Moderator
No problem, and yes, it looks like you have this right.
1. No, you'll just need to poll occasionally.
2. The complete result from finish batch itself is actually not currently used, and is just there for flexibility in the future. We may update that in the future to use that result and include the metadata there, but for now you won't get that.
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!