cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

how do I set my Swift Dropbox API .upload to overwrite

how do I set my Swift Dropbox API .upload to overwrite

dougnull
Explorer | Level 4
Go to solution

How do I make .upload overwrite the file if it's already in dropbox?

 

When my swift tries to upload an updated file, I get "API route" error if file already in dropbox.

I tried this:

let request = client!.files.upload( path: dropbox_upload_pathname, input: fileData, WriteMode: overwrite )

..but got error "Cannot find 'overwrite' in scope."

I tried these but get build errors...

client!.files.upload( path: dropbox_upload_pathname, WriteMode: overwrite, input: fileData)

client!.files.upload( path: dropbox_upload_pathname, input: fileData, WriteMode: overwrite)

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

[Cross-linking for reference: https://stackoverflow.com/questions/72060987/how-can-i-overwrite-a-file-using-dropbox-api-in-ios-swi... ]

 

The upload method takes a 'mode' parameter, for which the value should be a Files.WriteMode, like this:

client.files.upload(path: dropbox_upload_pathname, mode: Files.WriteMode.overwrite, input: fileData)
    .response { response, error in
        if let response = response {
            print(response)
        } else if let error = error {
            print(error)
        }
    }

 

For reference, you can use "overwrite", but "update" is recommended, as it's safer.

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution

[Cross-linking for reference: https://stackoverflow.com/questions/72060987/how-can-i-overwrite-a-file-using-dropbox-api-in-ios-swi... ]

 

The upload method takes a 'mode' parameter, for which the value should be a Files.WriteMode, like this:

client.files.upload(path: dropbox_upload_pathname, mode: Files.WriteMode.overwrite, input: fileData)
    .response { response, error in
        if let response = response {
            print(response)
        } else if let error = error {
            print(error)
        }
    }

 

For reference, you can use "overwrite", but "update" is recommended, as it's safer.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?