cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: [Python V2] How to do batch upload?

[Python V2] How to do batch upload?

ivanhigueram
Explorer | Level 4

Hi! 

I am trying to upload several files using the sessions and batch operators in the Dropbox SDK for Python. I'm trying to do something like this: 

dbx = dropbox.Dropbox(<API KEY>)

commit_info = []
for df in list_pandas_df: 
    df_raw_str = df.to_csv(index=False)
    upload_session = dbx.upload_session_start(df_raw_str.encode())
    commit_info.append(
dbx.files.CommitInfo(path=/path/to/db/folder.csv
) dbx.files_upload_finish_batch(commit_info)

But, I do not completely understand from the documentation, how should I pass the commit data and the session info to the "files_upload_session_finish_batch" function. The "files_upload_session_finish" function does allow a commit and a cursor, while the documentation states that the batch option only takes a list of commits. 

My files are not particularly big, but they are numerous. That's why I'm not using any of the appending options. Should I use any cursor? I'm a little bit lost here 😞 

12 Replies 12

Greg-DB
Dropbox Staff

@9krausec You'll need to poll files_upload_session_finish_batch_check to check on the result of the job. If you're not seeing anything uploaded, something must have failed, and the result from files_upload_session_finish_batch_check should tell you what it was.

9krausec
Explorer | Level 4

@Greg - Thank you again. No errors were returned. Just states that status is "in-progress"

UploadSessionFinishBatchJobStatus('in_progress', None)


I'll tell ya what - You follow me through here to the end and I bet this is going to be an excellent reference for everyone else using Python. I'm actually surprised I wasn't able to find a working example in this forum, or in the examples on git.

In the meantime I'll keep at it. 

Greg-DB
Dropbox Staff

@9krausec That indicates that the job is not done yet. You'll need to poll it until it's complete. That is, call it once every few seconds until it returns the result.

Need more support?