Managing Files and Folders with WebDAV > Moving or Renaming a File or Directory
Moving or Renaming a File or Directory
Internal WebDAV
Move or rename a file or a directory.
Object URI
File move: {INT_WEBDAV_URL}/OLD_File_path
Directory move: {INT_WEBDAV_URL}/Dir_path
HTTP Method
MOVE
Request Header
Destination: {INT_WEBDAV_URL}/New_path
Or (to move or rename the file):
Destination: {INT_WEBDAV_URL}/New_path_New_Name
Or (to overwrite the existing):
Destination: {INT_WEBDAV_URL}/New_path
Overwrite: T
Request Body
Empty
Expected Response status
201 Created or 200 OK
If a response such as 412 Precondition Failed is returned, the operation was canceled due to Overwrite being set to False.
If a response such as 401 Access Denied is returned, check the permissions.
External WebDAV
The following example uses a move function that assumes overwrite=true. While it is possible to work with this preset configuration, you can also override this preset by overriding the sardine client class move method. See Changing Sardine Client Constructor to Disallow Overwrite.
Java Example
To move a file or a directory from one path to another, use the following:
sardine.move({EXT_WEBDAV_URL} + "/" + source, {EXT_WEBDAV_URL}+ "/" + destination);