[英]Replace file on DropBox using DropBox Android API
I am working on an android project and am trying to add drop box functionality. 我正在研究一个Android项目,我正在尝试添加下拉框功能。 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. 例如,我正在上传名为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.
如果我再次尝试上传此文件,而不是替换文件,则会将其上传为MyFile(1).txt,然后下载MyFile(2).txt,依此类推。
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. 如何为每次上传替换此文件,或者我是否必须使用API删除文件然后执行上载。 Thanks for any help you can provide.
感谢您的任何帮助,您可以提供。
putFileOverwrite
might be what you're looking for? putFileOverwrite
可能正是您要找的?
public DropboxAPI.Entry putFileOverwrite(java.lang.String path,
java.io.InputStream is,
long length,
ProgressListener listener)
throws DropboxException
Uploads a file to Dropbox. 将文件上传到Dropbox。 The upload will overwrite any existing version of the file.
上传将覆盖该文件的任何现有版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.