Managing Files and Folders with WebDAV > Copying a File or Directory
Copying a File or Directory
Internal WebDAV
Copy a file or a directory.
Object URI
File copy: {INT_WEBDAV_URL}/OLD_File_path
Directory copy: {INT_WEBDAV_URL}/Dir_path
HTTP Method
COPY
Request Header
Destination: {INT_WEBDAV_URL}/New_path
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 copy method. See Changing Sardine Client Constructor to Disallow Overwrite.
Java Example
To copy a file or a folder form one path to another, use:
sardine.copy(EXT_WEBDAV_URL + "/" + source, EXT_WEBDAV_URL + "/" + destination);