java - 如果文件已存在于 Dropbox 中,如何覆盖该文件?

标签 java android dropbox

我正在通过以下方法在保管箱中上传文件:

public void upload() {

        FileInputStream inputStream = null;
        try {
            File file = new File(Environment.getExternalStorageDirectory()
                    .toString() + "/write.txt");
            inputStream = new FileInputStream(file);
            Entry newEntry = mDBApi.putFile("/write.txt", inputStream,
                    file.length(), null, null);
            Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
        } catch (DropboxUnlinkedException e) {
            // User has unlinked, ask them to link again here.
            Log.e("DbExampleLog", "User has unlinked.");
        } catch (DropboxException e) {
            Log.e("DbExampleLog", "Something went wrong while uploading.");
        } catch (FileNotFoundException e) {
            Log.e("DbExampleLog", "File not found.");
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                }
            }
        }

    }

但是当该文件已存在于文件夹中时,该文件将被重命名为 write(1).txt 但我希望如果该文件已存在于 dropbox 共享文件夹中,那么它将被替换。我现在应该做什么?

最佳答案

您可以使用mDBApi.putFileOverwrite代替mDBApi.putFile

关于java - 如果文件已存在于 Dropbox 中,如何覆盖该文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11490480/

相关文章:

java - JSlider 旋钮未更新(基本 Java)

Java inputevents 在 linux 中有一段时间没有触发(java/xorg 问题??)

android - 改造httpLogInterceptor java.lang.NoSuchMethodError :

android - 我想在 fragment 中创建图像幻灯片 View ?

javascript - 在 NodeJS 中下载 Dropbox 文件的内容

backup - 自动文件版本控制(例如Dropbox)

java - 嵌套 while 循环迭代

java - 从我的 Java 应用程序中备份 MySql

Android - 如何使此警报对话框可滚动?

iphone - 使用 DropBox SDK 的 iPhone 应用程序未调用 handOpenURL