FTPClient
FTPFileInfo
HTTPClient
HTTPClientLoggingConfig
HTTPRequestPart
Mail
SFTPClient
SFTPFileInfo
WebDAVClient
WebDAVFileInfo
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
The WebDAVClient class supports the WebDAV methods GET, PUT, MKCOL, MOVE, COPY, PROPFIND,OPTIONS and DELETE.
Note: when this class is used with sensitive data, be careful in persisting sensitive information to disk. The client can be used as shown in the following example:
1var webdavClient : WebDAVClient = new WebDAVClient("http://mywebdav.server.com","myusername", "mypassword");
2var getString : String = webdavClient.get("myData.xml","UTF-8");
3var message : String;
4
5if (webdavClient.succeeded())
6{
7 message = webDavClient.statusText;
8}
9else
10{
11 // error handling
12 message="An error occurred with status code "+webdavClient.statusCode;
13}
14
15var data : XML = new XML(getString);The WebDAV client supports the following authentication schemes:
The methods of this class do not generally throw exceptions if the underlying WebDAV operation do not succeed.The result of a WebDAV operation can be checked using the methods succeeded(), getStatusCode(), and getStatusText().
Important note: This WebDAV client cannot be used to access the Commerce Cloud Digital server via WebDAV protocol.
| Constant | Description |
|---|---|
| DEFAULT_ENCODING: String = “UTF-8” | The default encoding character set. |
| DEFAULT_GET_FILE_SIZE: Number = 5242880 | The default size for get() returning a File is 5MB. |
| DEFAULT_GET_STRING_SIZE: Number = 2097152 | The default size for get() returning a String is 2MB. |
| DEPTH_0: Number = 0 | The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be searched only on the level of the given path and a list of all containing files on that level will be returned [is not supported by every server]. |
| DEPTH_1: Number = 1 | The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be searched until one level under the given path and a list of all containing files in that two levels [/path and one level underneath] will be returned [is not supported by every server]. |
| DEPTH_INIFINITY: Number = 2147483647 | The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be fully searched and a list of all containing files will be returned [is not supported by every server]. |
| MAX_GET_FILE_SIZE: Number = 209715200 | The maximum size for get() returning a File is forty times the default size for getting a file. |
| MAX_GET_STRING_SIZE: Number = 10485760 | The maximum size for get() returning a String is five times the default size for getting a String. |
| Property | Description |
|---|---|
allResponseHeaders: HashMap (read-only) | Returns a HashMap of all response headers. |
statusCode: Number (read-only) | Returns the status code after the execution of a method. |
statusText: String (read-only) | Returns the status text after the execution of a method. |
| Constructor | Description |
|---|---|
| WebDAVClient(String, String, String) | Creates a new client for the use at a server which requires authentication. |
| WebDAVClient(String) | Creates a new client for the use at a server which does not require authentication. |
| Method | Description |
|---|---|
| addRequestHeader(String, String) | Adds a request header to the next WebDAV call. |
| close() | Closes the current connection to the server. |
| copy(String, String) | Copies a file on the server from one place rootUrl/origin to the other rootUrl/destination. |
| copy(String, String, Boolean) | Copies a file on the server from one place rootUrl/origin to the other rootUrl/destination. |
| copy(String, String, Boolean, Boolean) | Copies a file on the server from one place rootUrl/origin to the other rootUrl/destination. |
| del(String) | Deletes a file or directory from the remote server that can be found under rootUrl/path. |
| get(String) | Reads the content of a remote file or directory that can be found under rootUrl/path and returns a string representation of the data found in the DEFAULT_ENCODING encoding. |
| get(String, File) | Reads the content of a remote file or directory that can be found under rootUrl/path in DEFAULT_ENCODING encoding and writes a File in the system’s standard encoding, which is “UTF-8”. |
| get(String, File, Number) | Reads the content of a remote file or directory that can be found under rootUrl/path in DEFAULT_ENCODING encoding and writes a File in the system’s standard encoding, which is “UTF-8”. |
| get(String, File, String, Number) | Reads the content of a remote file or directory that can be found under rootUrl/path in the passed encoding and writes a File in the system standard encoding, which is “UTF-8”. |
| get(String, String) | Reads the content of a remote file or directory that can be found under rootUrl/path and returns a string representation of the data found in the given encoding. |
| get(String, String, Number) | Reads the content of a remote file or directory that can be found under rootUrl/path and returns a string representation of the data found in the given encoding. |
| getAllResponseHeaders() | Returns a HashMap of all response headers. |
| getBinary(String, File) | Reads the content of a remote binary file that can be found under rootUrl/path and creates a local copy in File. |
| getBinary(String, File, Number) | Reads the content of a remote binary file that can be found under rootUrl/path and creates a local copy in File. |
| getResponseHeader(String) | Returns a specified response header - multiple headers are separated by CRLF. |
| getStatusCode() | Returns the status code after the execution of a method. |
| getStatusText() | Returns the status text after the execution of a method. |
| mkcol(String) | Creates a directory on the remote server on the location rootUrl/path. |
| move(String, String) | Moves a file on the server from one place rootUrl + ”/” +origin to the other rootUrl/destination. |
| move(String, String, Boolean) | Moves a file on the server from one place rootUrl/origin to the other rootUrl/destination Can also be used to rename a remote file. |
| options(String) | Returns a list of methods which can be executed on the server location rootUrl/path. |
| propfind(String) | Get file listing of a remote location. |
| propfind(String, Number) | Get file listing of a remote location. |
| put(String, File) | Puts content out of a passed local file into a remote located file at rootUrl/path. |
| put(String, String) | Puts content encoded with DEFAULT_ENCODING into a remote located file at rootUrl/path. |
| put(String, String, String) | Puts content encoded with the passed encoding into a remote located file at rootUrl/path. |
| succeeded() | Returns true if the last executed WebDAV method was executed successfully - otherwise false. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
The default encoding character set.
The default size for get() returning a File is 5MB.
The default size for get() returning a String is 2MB.
The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be searched only on the level of the given path and a list of all containing files on that level will be returned [is not supported by every server].
The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be searched until one level under the given path and a list of all containing files in that two levels [/path and one level underneath] will be returned [is not supported by every server].
The depth of searching a WebDAV destination using the PROPFIND method - if that depth is given to the PROPFIND method as an input parameter the destination will be fully searched and a list of all containing files will be returned [is not supported by every server].
The maximum size for get() returning a File is forty times
the default size for getting a file. The largest file allowed is 200MB.
The maximum size for get() returning a String is five
times the default size for getting a String. The largest String allowed
is 10MB.
(read-only)Returns the status code after the execution of a method.
(read-only)Returns the status text after the execution of a method.
Creates a new client for the use at a server which requires authentication. The client supports the following authentication schemes: - Basic authentication scheme - Digest authentication scheme
Parameters:
Creates a new client for the use at a server which does not require authentication.
Parameters:
Adds a request header to the next WebDAV call.
Parameters:
Closes the current connection to the server.
Copies a file on the server from one place rootUrl/origin
to the other rootUrl/destination. If
destination already exists it gets overwritten. Returns
true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.rootUrl stated when instantiating the client.Returns:
Copies a file on the server from one place rootUrl/origin
to the other rootUrl/destination. If
the passed parameter overwrite is true and
destination already exists it gets overwritten. Returns
true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.rootUrl stated when instantiating the client.Returns:
Copies a file on the server from one place rootUrl/origin
to the other rootUrl/destination. If
the passed parameter overwrite is true and
destination already exists it gets overwritten. If the
passed parameter shallow is true a flat copy mechanism is
used.
Returns true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.rootUrl stated when instantiating the client.Returns:
Deletes a file or directory from the remote server that can be found
under rootUrl/path. Returns true if
succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path and returns a string
representation of the data found in the DEFAULT_ENCODING encoding. If the
remote location is a directory the result depends on the server
configuration, some return an HTML formatted directory listing. Returns
at most DEFAULT_GET_STRING_SIZE bytes.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path in DEFAULT_ENCODING
encoding and writes a File in the system's standard
encoding, which is "UTF-8". If the remote location is a directory the
result depends on the server configuration, some return an HTML formatted
directory listing. Receives at most DEFAULT_GET_FILE_SIZE bytes which
determines the file size of the local file. Returns true if succeeded
otherwise false.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path in DEFAULT_ENCODING
encoding and writes a File in the system's standard
encoding, which is "UTF-8". If the remote location is a directory the
result depends on the server configuration, some return an HTML formatted
directory listing. Receives at most maxFileSize bytes which determines
the file size of the local file. Returns true if succeeded, otherwise
false.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path in the passed encoding and
writes a File in the system standard encoding, which is
"UTF-8". If the remote location is a directory the result depends on the
server configuration, some return an HTML formatted directory listing.
Receives at most maxFileSize bytes which determines the file size of the
local file. Returns true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path and returns a string
representation of the data found in the given encoding. If
the remote location is a directory the result depends on the server
configuration, some return an HTML formatted directory listing. Returns
at most DEFAULT_GET_STRING_SIZE bytes.
Parameters:
rootUrl stated when instantiating the client.Returns:
Reads the content of a remote file or directory that can be found under
rootUrl/path and returns a string
representation of the data found in the given encoding. If
the remote location is a directory the result depends on the server
configuration, some return an HTML formatted directory listing. Returns
at most maxGetSize bytes.
Parameters:
rootUrl stated when instantiating the client.Returns:
Returns a HashMap of all response headers.
Returns:
Reads the content of a remote binary file that can be found under
rootUrl/path and creates a local copy
in File. If the remote location is a directory the result
depends on the server configuration, some return an HTML formatted
directory listing. Copies at most DEFAULT_GET_FILE_SIZE bytes. Returns
true if succeeded, otherwise false.
Parameters:
rootUrl on the remote server including the file name.Returns:
Reads the content of a remote binary file that can be found under
rootUrl/path and creates a local copy
in File. If the remote location is a directory the result
depends on the server configuration, some return an HTML formatted
directory listing. Copies at most maxFileSize bytes. Returns true if
succeeded, otherwise false.
Parameters:
rootUrl on the remote server including the file name.Returns:
Returns a specified response header - multiple headers are separated by CRLF.
Parameters:
Returns:
Returns the status code after the execution of a method.
Returns:
statusCode.Returns the status text after the execution of a method.
Returns:
statusText.Creates a directory on the remote server on the location
rootUrl/path.
Parameters:
rootUrl stated when instantiating the client where the new collection should be created.Returns:
Moves a file on the server from one place rootUrl + "/" +origin
to the other rootUrl/destination. If
destination already exists it gets overwritten. Can also
be used to rename a remote file. Returns true if succeeded, otherwise
false.
Parameters:
rootUrl stated when instantiating the client.rootUrl stated when instantiating the client.Returns:
Moves a file on the server from one place rootUrl/origin
to the other rootUrl/destination Can
also be used to rename a remote file. If overwrite is true
and destination already exists it gets overwritten.
Returns true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.rootUrl stated when instantiating the client.Returns:
Returns a list of methods which can be executed on the server location
rootUrl/path.
Parameters:
rootUrl stated when instantiating the client one wants to get the options for.Returns:
Get file listing of a remote location.
Returns a list of WebDAVFileInfo objects which contain
information about the files and directories located on
rootUrl/path and DEPTH_1 (1) level
underneath.
Parameters:
rootUrl stated when instantiating the client where to get information about the containing files from.Returns:
Get file listing of a remote location.
Returns a list of WebDAVFileInfo objects which contain
information about the files and directories located on
rootUrl/path and the passed depth
underneath.
Parameters:
rootUrl stated when instantiating the client where to get information about the containing files from.rootUrl down to which the file information gets collected.Returns:
Puts content out of a passed local file into a remote located file
at rootUrl/path. This method performs
a binary file transfer. Returns true if succeeded, otherwise false.
Parameters:
rootUrl stated when instantiating the client.Returns:
Puts content encoded with DEFAULT_ENCODING into a remote located file at
rootUrl/path. Returns true if
succeeded, otherwise false.
If the content of a local file is to be uploaded, please use method put(String, File) instead.
Parameters:
rootUrl stated when instantiating the client.Returns:
Puts content encoded with the passed encoding into a remote located file
at rootUrl/path. Returns true if
succeeded, otherwise false.
If the content of a local file is to be uploaded, please use method put(String, File) instead.
Parameters:
rootUrl stated when instantiating the client.Returns:
Returns true if the last executed WebDAV method was executed successfully - otherwise false. See the code snippet above for an example how to use the succeed() method.
Returns:
See Also: