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.
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.
Labels: Delete. Sync and upload.
Try this one, from Dropbox SDK Example.
dbx.files_upload(data, '/file.py', mode=dropbox.files.WriteMode.overwrite)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With