1 | ## Modules
|
2 |
|
3 | <dl>
|
4 | <dt><a href="#module_WebDAV">WebDAV</a> ⇒ <code><a href="#ClientInterface">ClientInterface</a></code></dt>
|
5 | <dd><p>Create a client adapter</p>
|
6 | </dd>
|
7 | </dl>
|
8 |
|
9 | ## Functions
|
10 |
|
11 | <dl>
|
12 | <dt><a href="#encodePath">encodePath(path)</a> ⇒ <code>String</code></dt>
|
13 | <dd><p>Encode a path for use with WebDAV servers</p>
|
14 | </dd>
|
15 | <dt><a href="#setFetchMethod">setFetchMethod(fn)</a></dt>
|
16 | <dd><p>Set the fetch method to use when making requests
|
17 | Defaults to <code>node-fetch</code>. Setting it to <code>null</code> will reset it to <code>node-fetch</code>.</p>
|
18 | </dd>
|
19 | </dl>
|
20 |
|
21 | ## Typedefs
|
22 |
|
23 | <dl>
|
24 | <dt><a href="#ClientInterface">ClientInterface</a> : <code>Object</code></dt>
|
25 | <dd><p>Client adapter</p>
|
26 | </dd>
|
27 | <dt><a href="#OptionsWithHeaders">OptionsWithHeaders</a> : <code>Object</code></dt>
|
28 | <dd><p>Options with header object</p>
|
29 | </dd>
|
30 | <dt><a href="#PutOptions">PutOptions</a> : <code><a href="#OptionsWithHeaders">OptionsWithHeaders</a></code></dt>
|
31 | <dd><p>Options for creating a resource</p>
|
32 | </dd>
|
33 | </dl>
|
34 |
|
35 | <a name="module_WebDAV"></a>
|
36 |
|
37 | ## WebDAV ⇒ [<code>ClientInterface</code>](#ClientInterface)
|
38 | Create a client adapter
|
39 |
|
40 | **Returns**: [<code>ClientInterface</code>](#ClientInterface) - A new client interface instance
|
41 |
|
42 | | Param | Type | Description |
|
43 | | --- | --- | --- |
|
44 | | remoteURL | <code>String</code> | The remote address of the webdav server |
|
45 | | [username] | <code>String</code> | Optional username for authentication |
|
46 | | [password] | <code>String</code> | Optional password for authentication |
|
47 |
|
48 | **Example**
|
49 | ```js
|
50 | const createClient = require("webdav");
|
51 | const client = createClient(url, username, password);
|
52 | client
|
53 | .getDirectoryContents("/")
|
54 | .then(contents => {
|
55 | console.log(contents);
|
56 | });
|
57 | ```
|
58 | **Example**
|
59 | ```js
|
60 | const createClient = require("webdav");
|
61 | const client = createClient(url, {token_type: 'Bearer', access_token: 'tokenvalue'});
|
62 | client
|
63 | .getDirectoryContents("/")
|
64 | .then(contents => {
|
65 | console.log(contents);
|
66 | });
|
67 | ```
|
68 | <a name="encodePath"></a>
|
69 |
|
70 | ## encodePath(path) ⇒ <code>String</code>
|
71 | Encode a path for use with WebDAV servers
|
72 |
|
73 | **Kind**: global function
|
74 | **Returns**: <code>String</code> - The encoded path (separators protected)
|
75 |
|
76 | | Param | Type | Description |
|
77 | | --- | --- | --- |
|
78 | | path | <code>String</code> | The path to encode |
|
79 |
|
80 | <a name="setFetchMethod"></a>
|
81 |
|
82 | ## setFetchMethod(fn)
|
83 | Set the fetch method to use when making requests
|
84 | Defaults to `node-fetch`. Setting it to `null` will reset it to `node-fetch`.
|
85 |
|
86 | **Kind**: global function
|
87 |
|
88 | | Param | Type | Description |
|
89 | | --- | --- | --- |
|
90 | | fn | <code>function</code> | Function to use - should perform like `fetch`. |
|
91 |
|
92 | **Example**
|
93 | ```js
|
94 | const createClient = require("webdav");
|
95 | createClient.setFetchMethod(window.fetch);
|
96 | ```
|
97 | <a name="ClientInterface"></a>
|
98 |
|
99 | ## ClientInterface : <code>Object</code>
|
100 | Client adapter
|
101 |
|
102 | **Kind**: global typedef
|
103 |
|
104 | * [ClientInterface](#ClientInterface) : <code>Object</code>
|
105 | * [.copyFile(remotePath, targetRemotePath, [options])](#ClientInterface.copyFile) ⇒ <code>Promise</code>
|
106 | * [.createDirectory(dirPath, [options])](#ClientInterface.createDirectory) ⇒ <code>Promise</code>
|
107 | * [.createReadStream(remoteFilename, [options])](#ClientInterface.createReadStream) ⇒ <code>Readable</code>
|
108 | * [.createWriteStream(remoteFilename, [options])](#ClientInterface.createWriteStream) ⇒ <code>Writeable</code>
|
109 | * [.deleteFile(remotePath, [options])](#ClientInterface.deleteFile) ⇒ <code>Promise</code>
|
110 | * [.getDirectoryContents(remotePath, [options])](#ClientInterface.getDirectoryContents) ⇒ <code>Promise.<Array></code>
|
111 | * [.getFileContents(remoteFilename, [options])](#ClientInterface.getFileContents) ⇒ <code>Promise.<(Buffer\|String)></code>
|
112 | * [.getFileDownloadLink(remoteFilename, [options])](#ClientInterface.getFileDownloadLink) ⇒ <code>String</code>
|
113 | * [.getQuota([options])](#ClientInterface.getQuota) ⇒ <code>null</code> \| <code>Object</code>
|
114 | * [.moveFile(remotePath, targetRemotePath, [options])](#ClientInterface.moveFile) ⇒ <code>Promise</code>
|
115 | * [.putFileContents(remoteFilename, data, [options])](#ClientInterface.putFileContents) ⇒ <code>Promise</code>
|
116 | * [.stat(remotePath, [options])](#ClientInterface.stat) ⇒ <code>Promise.<Object></code>
|
117 |
|
118 | <a name="ClientInterface.copyFile"></a>
|
119 |
|
120 | ### ClientInterface.copyFile(remotePath, targetRemotePath, [options]) ⇒ <code>Promise</code>
|
121 | Copy a remote item to another path
|
122 |
|
123 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
124 | **Returns**: <code>Promise</code> - A promise that resolves once the request has completed
|
125 |
|
126 | | Param | Type | Description |
|
127 | | --- | --- | --- |
|
128 | | remotePath | <code>String</code> | The remote item path |
|
129 | | targetRemotePath | <code>String</code> | The path file will be copied to |
|
130 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the request |
|
131 |
|
132 | <a name="ClientInterface.createDirectory"></a>
|
133 |
|
134 | ### ClientInterface.createDirectory(dirPath, [options]) ⇒ <code>Promise</code>
|
135 | Create a directory
|
136 |
|
137 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
138 | **Returns**: <code>Promise</code> - A promise that resolves when the remote path has been created
|
139 |
|
140 | | Param | Type | Description |
|
141 | | --- | --- | --- |
|
142 | | dirPath | <code>String</code> | The path to create |
|
143 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the request |
|
144 |
|
145 | <a name="ClientInterface.createReadStream"></a>
|
146 |
|
147 | ### ClientInterface.createReadStream(remoteFilename, [options]) ⇒ <code>Readable</code>
|
148 | Create a readable stream of a remote file
|
149 |
|
150 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
151 | **Returns**: <code>Readable</code> - A readable stream
|
152 |
|
153 | | Param | Type | Description |
|
154 | | --- | --- | --- |
|
155 | | remoteFilename | <code>String</code> | The file to stream |
|
156 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the request |
|
157 |
|
158 | <a name="ClientInterface.createWriteStream"></a>
|
159 |
|
160 | ### ClientInterface.createWriteStream(remoteFilename, [options]) ⇒ <code>Writeable</code>
|
161 | Create a writeable stream to a remote file
|
162 |
|
163 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
164 | **Returns**: <code>Writeable</code> - A writeable stream
|
165 |
|
166 | | Param | Type | Description |
|
167 | | --- | --- | --- |
|
168 | | remoteFilename | <code>String</code> | The file to write to |
|
169 | | [options] | [<code>PutOptions</code>](#PutOptions) | Options for the request |
|
170 |
|
171 | <a name="ClientInterface.deleteFile"></a>
|
172 |
|
173 | ### ClientInterface.deleteFile(remotePath, [options]) ⇒ <code>Promise</code>
|
174 | Delete a remote file
|
175 |
|
176 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
177 | **Returns**: <code>Promise</code> - A promise that resolves when the remote file as been deleted
|
178 |
|
179 | | Param | Type | Description |
|
180 | | --- | --- | --- |
|
181 | | remotePath | <code>String</code> | The remote path to delete |
|
182 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | The options for the request |
|
183 |
|
184 | <a name="ClientInterface.getDirectoryContents"></a>
|
185 |
|
186 | ### ClientInterface.getDirectoryContents(remotePath, [options]) ⇒ <code>Promise.<Array></code>
|
187 | Get the contents of a remote directory
|
188 |
|
189 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
190 | **Returns**: <code>Promise.<Array></code> - A promise that resolves with an array of remote item stats
|
191 |
|
192 | | Param | Type | Description |
|
193 | | --- | --- | --- |
|
194 | | remotePath | <code>String</code> | The path to fetch the contents of |
|
195 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the remote the request |
|
196 |
|
197 | <a name="ClientInterface.getFileContents"></a>
|
198 |
|
199 | ### ClientInterface.getFileContents(remoteFilename, [options]) ⇒ <code>Promise.<(Buffer\|String)></code>
|
200 | Get the contents of a remote file
|
201 |
|
202 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
203 | **Returns**: <code>Promise.<(Buffer\|String)></code> - A promise that resolves with the contents of the remote file
|
204 |
|
205 | | Param | Type | Description |
|
206 | | --- | --- | --- |
|
207 | | remoteFilename | <code>String</code> | The file to fetch |
|
208 | | [options] | <code>OptionsHeadersAndFormat</code> | Options for the request |
|
209 |
|
210 | <a name="ClientInterface.getFileDownloadLink"></a>
|
211 |
|
212 | ### ClientInterface.getFileDownloadLink(remoteFilename, [options]) ⇒ <code>String</code>
|
213 | Get the download link of a remote file
|
214 | Only supported for Basic authentication or unauthenticated connections.
|
215 |
|
216 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
217 | **Returns**: <code>String</code> - A download URL
|
218 |
|
219 | | Param | Type | Description |
|
220 | | --- | --- | --- |
|
221 | | remoteFilename | <code>String</code> | The file url to fetch |
|
222 | | [options] | <code>OptionsHeadersAndFormat</code> | Options for the request |
|
223 |
|
224 | <a name="ClientInterface.getQuota"></a>
|
225 |
|
226 | ### ClientInterface.getQuota([options]) ⇒ <code>null</code> \| <code>Object</code>
|
227 | Get quota information
|
228 |
|
229 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
230 | **Returns**: <code>null</code> \| <code>Object</code> - Returns null if failed, or an object with `used` and `available`
|
231 |
|
232 | | Param | Type | Description |
|
233 | | --- | --- | --- |
|
234 | | [options] | <code>OptionsHeadersAndFormat</code> | Options for the request |
|
235 |
|
236 | <a name="ClientInterface.moveFile"></a>
|
237 |
|
238 | ### ClientInterface.moveFile(remotePath, targetRemotePath, [options]) ⇒ <code>Promise</code>
|
239 | Move a remote item to another path
|
240 |
|
241 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
242 | **Returns**: <code>Promise</code> - A promise that resolves once the request has completed
|
243 |
|
244 | | Param | Type | Description |
|
245 | | --- | --- | --- |
|
246 | | remotePath | <code>String</code> | The remote item path |
|
247 | | targetRemotePath | <code>String</code> | The new path after moving |
|
248 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the request |
|
249 |
|
250 | <a name="ClientInterface.putFileContents"></a>
|
251 |
|
252 | ### ClientInterface.putFileContents(remoteFilename, data, [options]) ⇒ <code>Promise</code>
|
253 | Write contents to a remote file path
|
254 |
|
255 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
256 | **Returns**: <code>Promise</code> - A promise that resolves once the contents have been written
|
257 |
|
258 | | Param | Type | Description |
|
259 | | --- | --- | --- |
|
260 | | remoteFilename | <code>String</code> | The path of the remote file |
|
261 | | data | <code>String</code> \| <code>Buffer</code> | The data to write |
|
262 | | [options] | [<code>PutOptions</code>](#PutOptions) | The options for the request |
|
263 |
|
264 | <a name="ClientInterface.stat"></a>
|
265 |
|
266 | ### ClientInterface.stat(remotePath, [options]) ⇒ <code>Promise.<Object></code>
|
267 | Stat a remote object
|
268 |
|
269 | **Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
|
270 | **Returns**: <code>Promise.<Object></code> - A promise that resolves with the stat data
|
271 |
|
272 | | Param | Type | Description |
|
273 | | --- | --- | --- |
|
274 | | remotePath | <code>String</code> | The path of the item |
|
275 | | [options] | [<code>OptionsWithHeaders</code>](#OptionsWithHeaders) | Options for the request |
|
276 |
|
277 | <a name="OptionsWithHeaders"></a>
|
278 |
|
279 | ## OptionsWithHeaders : <code>Object</code>
|
280 | Options with header object
|
281 |
|
282 | **Kind**: global typedef
|
283 | **Properties**
|
284 |
|
285 | | Name | Type | Description |
|
286 | | --- | --- | --- |
|
287 | | headers | <code>Object</code> | Headers key-value list |
|
288 |
|
289 | <a name="PutOptions"></a>
|
290 |
|
291 | ## PutOptions : [<code>OptionsWithHeaders</code>](#OptionsWithHeaders)
|
292 | Options for creating a resource
|
293 |
|
294 | **Kind**: global typedef
|
295 | **Properties**
|
296 |
|
297 | | Name | Type | Description |
|
298 | | --- | --- | --- |
|
299 | | [overwrite] | <code>Boolean</code> | Whether or not to overwrite existing files (default: true) |
|
300 |
|