Skip to content

Commit

Permalink
Merge pull request #1007 from StCyr/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jul 9, 2024
2 parents 235a586 + 15e7ccc commit b9ff668
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 b9ff668

Please sign in to comment.