0

私はこの方法でドロップボックスにファイルをアップロードしています:

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に変更されますが、ファイルがドロップボックス共有フォルダーに既に存在する場合は、置き換えられます。私は今どうすればいい?

4

1 に答える 1

1

mDBApi.putFileOverwrite代わりに使用できますmDBApi.putFile

于 2013-02-22T19:55:27.017 に答える