11

I'm trying to overwrite a file on Dropbox with Python 3.4 but can't figure out how to do it. If the file doesn't exist, dbx.files_upload(data, '/file.py') creates the file as expected.

But if the file exists, I want to overwrite it. I've tried

dbx.files_upload(data, '/file.py', mode=WriteMode('overwrite'))

which gives

NameError: name 'WriteMode' is not defined

and I've tried

dbx.files_upload(data, '/iot_main.py', overwrite=True)

which gives

TypeError: files_upload() got an unexpected keyword argument 'overwrite'

I feel as if I'm missing something obvious but lots of Googling for an answer doesn't help...

Thanks.

2 Answers 2

28

Try this one, from Dropbox SDK Example.

dbx.files_upload(data, '/file.py', mode=dropbox.files.WriteMode.overwrite)
Sign up to request clarification or add additional context in comments.

1 Comment

For those seeking for the raw json input (to use in shell): {"path": "/some/file", "mode": "overwrite"}
7

just add this in your file.

from dropbox.files import WriteMode

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.