3.9.1 • Published 8 months ago
@nextcloud/files v3.9.1
@nextcloud/files
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; All its methods are available here.
Usage example
Using WebDAV to query favorite nodes
import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'
const client = davGetClient()
// query favorites for the root folder (meaning all favorites)
const favorites = await getFavoriteNodes(client)
// which is the same as writing:
const favorites = await getFavoriteNodes(client, '/', davRootPath)
Using WebDAV to list all nodes in directory
import {
davGetClient,
davGetDefaultPropfind,
davResultToNode,
davRootPath,
davRemoteURL
} from '@nextcloud/files'
// Get the DAV client for the default remote
const client = davGetClient()
// which is the same as writing
const client = davGetClient(davRemoteURL)
// of cause you can also configure another WebDAV remote
const client = davGetClient('https://example.com/dav')
const path = '/my-folder/' // the directory you want to list
// Query the directory content using the webdav library
// `davRootPath` is the files root, for Nextcloud this is '/files/USERID', by default the current user is used
const results = client.getDirectoryContents(`${davRootPath}${path}`, {
details: true,
// Query all required properties for a Node
data: davGetDefaultPropfind()
})
// Convert the result to an array of Node
const nodes = results.data.map((result) => davResultToNode(r))
// If you specified a different root in the `getDirectoryContents` you must add this also on the `davResultToNode` call:
const nodes = results.data.map((result) => davResultToNode(r, myRoot))
// Same if you used a different remote URL:
const nodes = results.data.map((result) => davResultToNode(r, myRoot, myRemoteURL))
Using WebDAV to get a Node from a file's name
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)
})
3.9.1
8 months ago
3.9.0
10 months ago
3.4.0
1 year ago
3.8.0
11 months ago
3.6.0
12 months ago
3.4.1
1 year ago
3.3.1
1 year ago
3.3.0
1 year ago
3.7.0
11 months ago
3.5.1
1 year ago
3.5.0
1 year ago
3.2.1
1 year ago
3.2.0
1 year ago
3.1.1
1 year ago
3.1.0
1 year ago
3.0.0-beta.20
2 years ago
3.0.0-beta.21
2 years ago
3.0.0-beta.22
2 years ago
3.0.0-beta.23
2 years ago
3.0.0-beta.24
2 years ago
3.0.0-beta.25
2 years ago
3.0.0-beta.26
2 years ago
3.0.0-beta.27
2 years ago
3.0.0-beta.19
2 years ago
3.0.0
2 years ago
3.0.0-beta.11
2 years ago
3.0.0-beta.12
2 years ago
3.0.0-beta.13
2 years ago
3.0.0-beta.14
2 years ago
3.0.0-beta.15
2 years ago
3.0.0-beta.16
2 years ago
3.0.0-beta.17
2 years ago
3.0.0-beta.18
2 years ago
3.0.0-beta.10
2 years ago
3.0.0-beta.9
2 years ago
3.0.0-beta.8
2 years ago
3.0.0-beta.7
2 years ago
3.0.0-beta.6
2 years ago
3.0.0-beta.5
3 years ago
3.0.0-beta.1
3 years ago
3.0.0-beta.3
3 years ago
3.0.0-beta.2
3 years ago
3.0.0-beta.4
3 years ago
3.0.1-beta.0
3 years ago
2.1.0
4 years ago
2.0.0
4 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
6 years ago
0.1.0
6 years ago