Skip to content

Commit

Permalink
Update README.md to add more info about the webDAV client
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrille Bollu <[email protected]>
  • Loading branch information
StCyr authored and Cyrille Bollu committed Jul 8, 2024
1 parent d6a05f9 commit 15e7ccc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# @nextcloud/files
[![npm last version](https://img.shields.io/npm/v/@nextcloud/files.svg?style=flat-square)](https://www.npmjs.com/package/@nextcloud/files) [![REUSE status](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-files)](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-files) [![Code coverage](https://img.shields.io/codecov/c/github/nextcloud-libraries/nextcloud-files?style=flat-square)](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-files) [![Project documentation](https://img.shields.io/badge/documentation-online-blue?style=flat-square)](https://nextcloud-libraries.github.io/nextcloud-files/)

Nextcloud Files helpers for Nextcloud apps and libraries
Nextcloud Files helpers for Nextcloud apps and libraries.

The `davGetClient` exported function returns a webDAV client that's a wrapper around [webdav's webDAV client](https://www.npmjs.com/package/webdav); All its methods are available here.

## Usage example

Expand Down Expand Up @@ -57,3 +59,18 @@ const nodes = results.data.map((result) => davResultToNode(r, myRoot))
const nodes = results.data.map((result) => davResultToNode(r, myRoot, myRemoteURL))

```

### Using WebDAV to get a Node from a file's name

```ts
import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
const client = davGetClient()
client.stat(`${davRootPath}${filename}`, {
details: true,
data: davGetDefaultPropfind(),
}).then((result) => {
const node = davResultToNode(result.data)
emit('files:node:updated', node)
})
```

0 comments on commit 15e7ccc

Please sign in to comment.