Overwrite/Don't overwrite option for Dropbox API Upload
Question: I have found the following script from an old StackOverflow question which
gives an example of how to connect to my Dropbox via the API:

    
    
    import dropbox
    
    client = dropbox.client.DropboxClient(<auth_token>)
    print 'linked account: ', client.account_info()
    
    f = open('working-draft.txt', 'rb')
    response = client.put_file('/magnum-opus.txt', f)
    print 'uploaded: ', response
    
    folder_metadata = client.metadata('/')
    print 'metadata: ', folder_metadata
    
    f, metadata = client.get_file_and_metadata('/magnum-opus.txt')
    out = open('magnum-opus.txt', 'wb')
    out.write(f.read())
    out.close()
    print metadata
    

I've played around with this and got it to upload the files I want to the
Dropbox sub folders I want. However, I am unsure how to specify whether to
overwrite a file already present on Dropbox with the same name or not. There
do not appear to be any example scripts written that cover this online
already.

The API documentation makes reference to an overwrite option as part of
chunked uploading
[here](https://www.dropbox.com/developers/core/docs/python#ChunkedUploader),
but I am unsure how I would work this into the example script shown above.

Can anyone assist?


Answer: The documentation for `put_file` is here:
<https://www.dropbox.com/developers/core/docs/python#DropboxClient.put_file>.

Just pass `overwrite=True` to overwrite. (The default is `False`.)

