Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overwrite a file with Dropbox API v2 in Python

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.

like image 367
Stuart Thomson Avatar asked Jan 23 '16 14:01

Stuart Thomson


People also ask

How do I overwrite files in Dropbox?

Open Dropbox and upload the file to the same location that you've uploaded the older one. Once the new file has uploaded, it will replace the old one. You will have only one file with that name in the folder. The share link for the old file will now work for this new file.

Does Dropbox overwrite files with same name?

Labels: Delete. Sync and upload.


1 Answers

Try this one, from Dropbox SDK Example.

dbx.files_upload(data, '/file.py', mode=dropbox.files.WriteMode.overwrite)
like image 134
silverfox Avatar answered Oct 11 '22 12:10

silverfox