We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
ijunaid8989
7 years agoExplorer | Level 3
too many write operations when uploading files
I am using Elixir wrapper to DropboxAPI to upload files, which is doing simple upload using `files/upload` route. def upload(client, path, file, mode \\ "add", autorename \\ true, mute \\ false) d...
Greg-DB
Dropbox Community Moderator
7 years agoIn this code I see you're using the 'finish' method, presumably once per file, to finish the uploads. If you send off multiple of these at the same time, you will cause lock contention.
You should use a single 'finish_batch' to finish multiple file uploads in a single call to avoid this. (Or, only send the multiple 'finish' calls one at a time.)
ijunaid8989
7 years agoExplorer | Level 3
I uploaded using session start and I got an session_id.
AAAAAAAb0vwx3ypjoH836Q
and then instead of doing append I just finished the batch of this file
curl -X POST https://api.dropboxapi.com/2/files/upload_session/finish_batch \
--header "Authorization: Bearer -SC69zip6zi9bwHgqhYHNYQbrpZ5C7G" \
--header "Content-Type: application/json" \
--data "{\"entries\": [{\"cursor\": {\"session_id\": \"AAAAAAAb0vwx3ypjoH836Q\",\"offset\": 34520},\"commit\": {\"path\": \"/REGULAR/licence\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}}]}"This gave me results as
{".tag": "async_job_id", "async_job_id": "dbjid:AACg_hehcOljTPYxh6wQhigGQhtc3-eCFneDKK--vzA5V9wBLNi74iNeNqWUQDFOnx1_k-sViaZJpJvXRG0UTlLw"}and whereas on normal session start and finish I just get the file uploaded moreover when I check batch as
curl -X POST https://api.dropboxapi.com/2/files/upload_session/finish_batch/check \
> --header "Authorization: Bearer -SC69zip6zi9bwHgqhYHNYQbrpZ5C7G" \
> --header "Content-Type: application/json" \
> --data "{\"async_job_id\": \"dbjid:AACg_hehcOljTPYxh6wQhigGQhtc3-eCFneDKK--vzA5V9wBLNi74iNeNqWUQDFOnx1_k-sViaZJpJvXRG0UTlLw\"}"it returns as
{".tag": "complete", "entries": [{".tag": "failure", "failure": {".tag": "lookup_failed", "lookup_failed": {".tag": "not_closed"}}}]}So now where I am wrong? the same file is getting uploaded through session start and finish but giving the error in this way?
- Greg-DB7 years ago
Dropbox Community Moderator
ijunaid8989 All of the upload sessions that you wish to finish using /finish_batch need to be "closed" before you call /finish_batch. That message is indicating that the upload session was not closed.
You should close the upload session with the last call you make to upload the final data for that upload session, whether that's on /start or /append, using the "close" parameter.
- ijunaid89897 years agoExplorer | Level 3
Thanks for all your replies and I have fixed this issue, my only question is right now, what could be the reason for timeouts from dropbox api?
I have timeout errors a few, while upload session start.
- Greg-DB7 years ago
Dropbox Community Moderator
Can you share the code and error output you're getting for these timeouts so we can take a look? Thanks!
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!