0

I am working on an android project and am trying to add drop box functionality. I've got it all pretty much working, I can successfully upload and download files without any problems but if I upload a file that already exists, I need it to be replaced, at the moment it will just add a number on the end.

For example, I am uploading a file called MyFile.txt. If I try and upload this file again, instead of the file being replaced it will upload it as MyFile(1).txt and the next time MyFile(2).txt and so on.

Below is the code I am using in order to upload the file.

File file = new File(Environment.getExternalStorageDirectory() + "/MyApp/dropbox_sync.xml");
FileInputStream inputStream = new FileInputStream(file);
Entry newEntry = mDBApi.putFile("android_sync.xml", inputStream, file.length(), null, null);

How can I replace this file for each upload, or do I have to use the API to delete the file and then perform the upload. Thanks for any help you can provide.

1 Answer 1

2

putFileOverwrite might be what you're looking for?

public DropboxAPI.Entry putFileOverwrite(java.lang.String path,
                                     java.io.InputStream is,
                                     long length,
                                     ProgressListener listener)
                              throws DropboxException

Uploads a file to Dropbox. The upload will overwrite any existing version of the file.

Sign up to request clarification or add additional context in comments.

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.