a-schild / nextcloud-java-api

Java api library to access nextcloud features from java applications
GNU General Public License v3.0
72 stars 50 forks source link

Move a file into a NextCloud folder #57

Closed mhalkiad closed 3 years ago

mhalkiad commented 3 years ago

Hi all, I am trying to move a file from one folder to another. Any help or example?

Thank you in advance.

a-schild commented 3 years ago

This is not yet implemented. https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/basic.html#moving-files-and-folders-rfc4918

We would need to use the move method from the sardine library

void move(String sourceUrl, String destinationUrl)

This moves a file from one location to another on the remote server. It assumes you want to overwrite all files.

Sardine sardine = SardineFactory.begin("username", "password"); 
sardine.move("http://yourdavserver.com/adirectory/file1.jpg", "http://yourdavserver.com/adirectory/file2.jpg");

It should be implemented in the api/webdav/Files.java file, similar to the upload method. I would accept a merge request for this ;)

a-schild commented 3 years ago

Is implemented in the 11.5.0 release