- getPatcher() ⇒
HotPatcher
Get the HotPatcher instance for patching internal methods
- encodePath(path) ⇒
String
Encode a path for use with WebDAV servers
- prepareRequestOptions(requestOptions, methodOptions)
Process request options before being passed to Axios
- request(requestOptions) ⇒
Promise.<Object>
Make a request This method can be patched by patching or plugging-in to the "request" item using HotPatcher. It uses Axios by default.
- ClientInterface :
Object
Client adapter
- PutOptions :
UserOptions
Options for creating a resource
- OptionsWithFormat :
UserOptions
Options with headers and format
- OptionsForAdvancedResponses :
UserOptions
Options for methods that resturn responses
- GetDirectoryContentsOptions :
OptionsForAdvancedResponses
- AuthToken :
Object
- CreateClientOptions :
Object
- Stat :
Object
A stat result
- UserOptions :
Object
- RequestOptions :
Object
- WebDAV
- .axios :
function
- .createClient(remoteURL, [options]) ⇒
ClientInterface
- .axios :
Axios request library
Kind: static property of WebDAV
WebDAV.createClient(remoteURL, [options]) ⇒ ClientInterface
Create a client adapter
Kind: static method of WebDAV
Returns: ClientInterface
- A new client interface instance
Param | Type | Description |
---|---|---|
remoteURL | String |
The remote address of the webdav server |
[options] | CreateClientOptions |
Client options |
Example
const createClient = require("webdav");
const client = createClient(url, { username, password });
client
.getDirectoryContents("/")
.then(contents => {
console.log(contents);
});
Example
const createClient = require("webdav");
const client = createClient(url, {
token: { token_type: "Bearer", access_token: "tokenvalue" }
});
client
.getDirectoryContents("/")
.then(contents => {
console.log(contents);
});
Get the HotPatcher instance for patching internal methods
Kind: global function
Returns: HotPatcher
- The internal HotPatcher instance
Encode a path for use with WebDAV servers
Kind: global function
Returns: String
- The encoded path (separators protected)
Param | Type | Description |
---|---|---|
path | String |
The path to encode |
Process request options before being passed to Axios
Kind: global function
Param | Type | Description |
---|---|---|
requestOptions | RequestOptions |
The request options object |
methodOptions | UserOptions |
Provided options (external) |
Make a request This method can be patched by patching or plugging-in to the "request" item using HotPatcher. It uses Axios by default.
Kind: global function
Returns: Promise.<Object>
- A promise that resolves with a response object
Param | Type | Description |
---|---|---|
requestOptions | RequestOptions |
Options for the request |
Client adapter
Kind: global typedef
- ClientInterface :
Object
- .copyFile(remotePath, targetRemotePath, [options]) ⇒
Promise
- .createDirectory(dirPath, [options]) ⇒
Promise
- .createReadStream(remoteFilename, [options]) ⇒
Readable
- .createWriteStream(remoteFilename, [options]) ⇒
Writeable
- .deleteFile(remotePath, [options]) ⇒
Promise
- .getDirectoryContents(remotePath, [options]) ⇒
Promise.<Array.<Stat>>
- .getFileContents(remoteFilename, [options]) ⇒
Promise.<(Buffer|String)>
- .getFileDownloadLink(remoteFilename, [options]) ⇒
String
- .getFileUploadLink(remoteFilename, [options]) ⇒
String
- .getQuota([options]) ⇒
Promise.<(null|Object)>
- .moveFile(remotePath, targetRemotePath, [options]) ⇒
Promise
- .putFileContents(remoteFilename, data, [options]) ⇒
Promise
- .stat(remotePath, [options]) ⇒
Promise.<Stat>
- .copyFile(remotePath, targetRemotePath, [options]) ⇒
Copy a remote item to another path
Kind: static method of ClientInterface
Returns: Promise
- A promise that resolves once the request has completed
Param | Type | Description |
---|---|---|
remotePath | String |
The remote item path |
targetRemotePath | String |
The path file will be copied to |
[options] | UserOptions |
Options for the request |
Example
await client.copyFile("/photos/pic1.jpg", "/backup/pic1.jpg");
Create a directory
Kind: static method of ClientInterface
Returns: Promise
- A promise that resolves when the remote path has been created
Param | Type | Description |
---|---|---|
dirPath | String |
The path to create |
[options] | UserOptions |
Options for the request |
Example
await client.createDirectory("/my/directory");
Create a readable stream of a remote file
Kind: static method of ClientInterface
Returns: Readable
- A readable stream
Param | Type | Description |
---|---|---|
remoteFilename | String |
The file to stream |
[options] | UserOptions |
Options for the request |
Example
const remote = client.createReadStream("/data.zip");
remote.pipe(someWriteStream);
Create a writeable stream to a remote file
Kind: static method of ClientInterface
Returns: Writeable
- A writeable stream
Param | Type | Description |
---|---|---|
remoteFilename | String |
The file to write to |
[options] | PutOptions |
Options for the request |
Example
const remote = client.createWriteStream("/data.zip");
fs.createReadStream("~/myData.zip").pipe(remote);
Delete a remote file
Kind: static method of ClientInterface
Returns: Promise
- A promise that resolves when the remote file as been deleted
Param | Type | Description |
---|---|---|
remotePath | String |
The remote path to delete |
[options] | UserOptions |
The options for the request |
Example
await client.deleteFile("/some/file.txt");
Get the contents of a remote directory
Kind: static method of ClientInterface
Returns: Promise.<Array.<Stat>>
- A promise that resolves with an array of remote item stats
Param | Type | Description |
---|---|---|
remotePath | String |
The path to fetch the contents of |
[options] | GetDirectoryContentsOptions |
Options for the remote the request |
Example
const contents = await client.getDirectoryContents("/");
Get the contents of a remote file
Kind: static method of ClientInterface
Returns: Promise.<(Buffer|String)>
- A promise that resolves with the contents of the remote file
Param | Type | Description |
---|---|---|
remoteFilename | String |
The file to fetch |
[options] | OptionsWithFormat |
Options for the request |
Example
// Fetching data:
const buff = await client.getFileContents("/image.png");
// Fetching text:
const txt = await client.getFileContents("/list.txt", { format: "text" });
Get the download link of a remote file Only supported for Basic authentication or unauthenticated connections.
Kind: static method of ClientInterface
Returns: String
- A download URL
Param | Type | Description |
---|---|---|
remoteFilename | String |
The file url to fetch |
[options] | UserOptions |
Options for the request |
Get a file upload link Only supported for Basic authentication or unauthenticated connections.
Kind: static method of ClientInterface
Returns: String
- A upload URL
Param | Type | Description |
---|---|---|
remoteFilename | String |
The path of the remote file location |
[options] | PutOptions |
The options for the request |
Get quota information
Kind: static method of ClientInterface
Returns: Promise.<(null|Object)>
- Returns null if failed, or an object with used
and available
Param | Type | Description |
---|---|---|
[options] | OptionsForAdvancedResponses |
Options for the request |
Move a remote item to another path
Kind: static method of ClientInterface
Returns: Promise
- A promise that resolves once the request has completed
Param | Type | Description |
---|---|---|
remotePath | String |
The remote item path |
targetRemotePath | String |
The new path after moving |
[options] | UserOptions |
Options for the request |
Example
await client.moveFile("/sub/file.dat", "/another/dir/file.dat");
Write contents to a remote file path
Kind: static method of ClientInterface
Returns: Promise
- A promise that resolves once the contents have been written
Param | Type | Description |
---|---|---|
remoteFilename | String |
The path of the remote file |
data | String | Buffer |
The data to write |
[options] | PutOptions |
The options for the request |
Example
await client.putFileContents("/dir/image.png", myImageBuffer);
// Put contents without overwriting:
await client.putFileContents("/dir/image.png", myImageBuffer, { overwrite: false });
ClientInterface.stat(remotePath, [options]) ⇒ Promise.<Stat>
Stat a remote object
Kind: static method of ClientInterface
Returns: Promise.<Stat>
- A promise that resolves with the stat data
Param | Type | Description |
---|---|---|
remotePath | String |
The path of the item |
[options] | OptionsForAdvancedResponses |
Options for the request |
PutOptions : UserOptions
Options for creating a resource
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[overwrite] | Boolean |
Whether or not to overwrite existing files (default: true) |
OptionsWithFormat : UserOptions
Options with headers and format
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
format | String |
The format to use (text/binary) |
[details] | Boolean |
Provided detailed response information, such as response headers (defaults to false). Only available on requests that return result data. |
OptionsForAdvancedResponses : UserOptions
Options for methods that resturn responses
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[details] | Boolean |
Provided detailed response information, such as response headers (defaults to false). Only available on requests that return result data. |
GetDirectoryContentsOptions : OptionsForAdvancedResponses
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[deep] | Boolean |
Return deep (infinite) items (default: false) |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
token_type | String |
The type of token (eg "Bearer") |
access_token | String |
The token access code |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[username] | String |
The username for authentication |
[password] | String |
The password for authentication |
[httpAgent] | http.Agent |
Override the HTTP Agent instance for requests |
[httpsAgent] | https.Agent |
Override the HTTPS Agent instance for requests |
[token] | AuthToken |
Optional OAuth token |
A stat result
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
filename | String |
The full path and filename of the remote item |
basename | String |
The base filename of the remote item, without the path |
lastmod | String |
The last modification date (eg. "Sun, 13 Mar 2016 04:23:32 GMT") |
size | Number |
The size of the remote item |
type | String |
The type of the item (file/directory) |
[mime] | String |
The file mimetype (not present on directories) |
etag | String | null |
The ETag of the remote item (as supported by the server) |
[props] | Object |
Additionally returned properties from the server, unprocessed, if details: true is specified in the options |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[httpAgent] | Object |
HTTP agent instance |
[httpsAgent] | Object |
HTTPS agent instance |
[headers] | Object |
Set additional request headers |
[withCredentials] | Boolean |
Set whether or not credentials should be included with the request. Defaults to value used by axios. |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
url | String |
The URL to request |
method | String |
The method to use (eg. "POST") |
[headers] | Object |
Headers to set on the request |
[httpAgent] | Object |
A HTTP agent instance |
[httpsAgent] | Object |
A HTTPS agent interface |
body | Object | String | * |
Body data for the request |