Constructor
new Client(options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Since:
- 8.2
- Source:
Members
_client :dav.Client
Client from the library
Type:
- dav.Client
- Source:
_fileInfoParsers :Array.<OC.Files.Client~parseFileInfo>
Array of file info parsing functions.
Type:
- Array.<OC.Files.Client~parseFileInfo>
- Source:
_root :string
Root path of the Webdav endpoint
Type:
- Source:
Methods
_buildPath(…path) → {String}
Append the path to the root and also encode path
sections
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
String |
<repeatable> |
sections |
- Source:
Returns:
joined path, any leading or trailing slash
will be kept
- Type
- String
_buildUrl(…path) → {String}
Prepends the base url to the given path sections
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
String |
<repeatable> |
sections |
- Source:
Returns:
base url + joined path, any leading or trailing slash
will be kept
- Type
- String
_getSabreException(response) → {Object}
Parse the Sabre exception out of the given response, if any
Parameters:
Name | Type | Description |
---|---|---|
response |
Object | object |
- Source:
Returns:
array of parsed message and exception (only the first one)
- Type
- Object
_isSuccessStatus(status)
Returns whether the given status code means success
Parameters:
Name | Type | Description |
---|---|---|
status |
int | status code |
- Source:
Returns:
true if status code is between 200 and 299 included
_parseEtag(etag) → {string}
Parses the etag response which is in double quotes.
Parameters:
Name | Type | Description |
---|---|---|
etag |
string | etag value in double quotes |
- Source:
Returns:
etag without double quotes
- Type
- string
_parseFileInfo(response) → {Array.<FileInfo>}
Parse Webdav result
Parameters:
Name | Type | Description |
---|---|---|
response |
Object | XML object |
- Source:
Returns:
array of file info
- Type
- Array.<FileInfo>
_parseHeaders(headersString) → {Object.<String, Array>}
Parse headers string into a map
Parameters:
Name | Type | Description |
---|---|---|
headersString |
string | headers list as string |
- Source:
Returns:
map of header name to header contents
- Type
- Object.<String, Array>
_parseResult(responses)
Parse Webdav multistatus
Parameters:
Name | Type | Description |
---|---|---|
responses |
Array |
- Source:
_xhrProvider() → {XMLHttpRequest}
Returns the configured XHR provider for davclient
- Source:
Returns:
- Type
- XMLHttpRequest
addFileInfoParser(parserFunction)
Add a file info parser function
Parameters:
Name | Type | Description |
---|---|---|
parserFunction |
OC.Files.Client~parseFileInfo |
- Source:
copy(path, destinationPath, allowOverwriteopt) → {Promise}
Copies path to another path
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
String | path to copy | ||
destinationPath |
String | destination path | ||
allowOverwrite |
boolean |
<optional> |
false | true to allow overwriting, false otherwise |
- Source:
Returns:
promise
- Type
- Promise
createDirectory(path) → {Promise}
Creates a directory
Parameters:
Name | Type | Description |
---|---|---|
path |
String | path to create |
- Source:
Returns:
- Type
- Promise
getBaseUrl() → {String}
Returns the base URL
- Since:
- 11.0.0
- Source:
Returns:
base URL
- Type
- String
getClient() → {dav.Client}
Returns the dav.Client instance used internally
- Since:
- 11.0.0
- Source:
Returns:
- Type
- dav.Client
getFileContents(path) → {Promise}
Returns the contents of the given file.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | path to file |
- Source:
Returns:
- Type
- Promise
getFileInfo(path) → {Promise}
Returns the file info of a given path.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
String | path | |
options.properties |
Array |
<optional> |
list of Webdav properties to retrieve |
- Source:
Returns:
promise
- Type
- Promise
getFilteredFiles(filter, optionsopt) → {Promise}
Fetches a flat list of files filtered by a given filter criteria.
(currently only system tags is supported)
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filter |
Object | filter criteria
Properties
|
|||||||||||||
options |
Object |
<optional> |
options
Properties
|
- Source:
Returns:
promise
- Type
- Promise
getFolderContents(path, optionsopt) → {Promise}
Lists the contents of a directory
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
String | path to retrieve | ||||||||||||||||
options |
Object |
<optional> |
options
Properties
|
- Source:
Returns:
promise
- Type
- Promise
getHost() → {String}
Returns the host
- Since:
- 13.0.0
- Source:
Returns:
base URL
- Type
- String
getPassword() → {String}
Returns the password
- Since:
- 11.0.0
- Source:
Returns:
password
- Type
- String
getPropfindProperties() → {Array.<Object>}
Returns the default PROPFIND properties to use during a call.
- Source:
Returns:
array of properties
- Type
- Array.<Object>
getUserName() → {String}
Returns the user name
- Since:
- 11.0.0
- Source:
Returns:
userName
- Type
- String
move(path, destinationPath, allowOverwriteopt, headersopt) → {Promise}
Moves path to another path
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
String | path to move | ||
destinationPath |
String | destination path | ||
allowOverwrite |
boolean |
<optional> |
false | true to allow overwriting, false otherwise |
headers |
Object |
<optional> |
null | additional headers |
- Source:
Returns:
promise
- Type
- Promise
putFileContents(path, body, optionsopt) → {Promise}
Puts the given data into the given file.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
String | path to file | ||||||||||||||||
body |
String | file body | ||||||||||||||||
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Promise
remove(path) → {Promise}
Deletes a file or directory
Parameters:
Name | Type | Description |
---|---|---|
path |
String | path to delete |
- Source:
Returns:
- Type
- Promise
Type Definitions
parseFileInfo(XML) → {Array}
File info parser function
This function receives a list of Webdav properties as input and
should return a hash array of parsed properties, if applicable.
Parameters:
Name | Type | Description |
---|---|---|
XML |
Object | Webdav properties |
- Source:
Returns:
array of parsed property values
- Type
- Array