You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
developersSave
2 years agoHelpful | Level 6
Move files and Folders
Hi everyone, I've a question: I need to move files and folders using dropbox API in my Java project. Do you have some code examples? I can't find them online and I don't know if it's possibile do ...
- 2 years ago
Hi Здравко ,
I solved everything in this way (all Paths are made with a DropBox id):
public static String moveFile(SuiteConfiguration suiteConfiguration,
String fromPath,String toPath) throws RelocationErrorException, DbxException {
DbxClientV2 dropboxClient = getV2Client(suiteConfiguration);
"id:TMSaeghsn0AAAAAAAACV2w/ios.png").withAllowOwnershipTransfer(true).withAllowSharedFolder(true).withAutorename(true);
RelocationResult result = dropboxClient.files().moveV2(fromPath, toPath);
return result.getMetadata().getPathDisplay();
}
public static void moveFolder(SuiteConfiguration suiteConfiguration,
String fromPath,String toPath) throws RelocationErrorException, DbxException, InterruptedException {
DbxClientV2 dropboxClient = getV2Client(suiteConfiguration);
MoveV2Builder withAllowSharedFolder = dropboxClient.files().moveV2Builder(fromPath,toPath).withAllowOwnershipTransfer(true).withAllowSharedFolder(true).withAutorename(false);
RelocationResult result = withAllowSharedFolder.start();
}
Thank you for your help
Здравко
Legendary | Level 20
developersSave wrote:...
I've to move "folder-2" under "My-App" folder, but I don't have any id for this one.
...
developersSave, You don't need id for your app namespace root folder. It's just empty. Pass an empty string instead of real ID. 😉 The concatenation can proceed without change.
developersSave
2 years agoHelpful | Level 6
Hi Здравко ,
I solved everything in this way (all Paths are made with a DropBox id):
public static String moveFile(SuiteConfiguration suiteConfiguration,
String fromPath,String toPath) throws RelocationErrorException, DbxException {
DbxClientV2 dropboxClient = getV2Client(suiteConfiguration);
"id:TMSaeghsn0AAAAAAAACV2w/ios.png").withAllowOwnershipTransfer(true).withAllowSharedFolder(true).withAutorename(true);
RelocationResult result = dropboxClient.files().moveV2(fromPath, toPath);
return result.getMetadata().getPathDisplay();
}
public static void moveFolder(SuiteConfiguration suiteConfiguration,
String fromPath,String toPath) throws RelocationErrorException, DbxException, InterruptedException {
DbxClientV2 dropboxClient = getV2Client(suiteConfiguration);
MoveV2Builder withAllowSharedFolder = dropboxClient.files().moveV2Builder(fromPath,toPath).withAllowOwnershipTransfer(true).withAllowSharedFolder(true).withAutorename(false);
RelocationResult result = withAllowSharedFolder.start();
}
Thank you for your help
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 14 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!