Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(drivers): webdav driver #276

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/content/6.drivers/webdav.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
navigation.title: WebDAV
---

# WebDAV

Store data on a WebDAV server such as [NextCloud](https://nextcloud.com/).

This driver implements meta for relavent [DAV properties](http://www.webdav.org/specs/rfc4918.html#dav.properties).

**Usage:**

```ts
import { createStorage } from "unstorage";
import webdavDriver, { type WebdavFile } from "unstorage/drivers/webdav";

const storage = createStorage({
driver: webdavDriver({
source: "https://docs.example.org/remote.php/dav/files/user",
username: "user",
password: "secret",
}),
});

const keys = await storage.getKeys();
const meta = (await storage.getMeta(
"Documents:Example.md"
)) as WebdavFile["meta"];
const content = await storage.getMeta("Documents:Example.md");
```

**Configuration Options:**

```js
export interface WebdavDriverOptions {
// URI of WebDAV share:
source: string;

// WebDAV username:
username?: string;

// WebDAV password:
password?: string;

// Specify additional headers:
headers?: { [key: string]: string };

// Expiration of cache:
ttl?: number;

// Provides fallback mechanism (recursive re-fetching of subdirectories)
// for any WebDAV service that does not support `Depth: "infinity"` header:
infinityDepthHeaderUnavailable?: boolean;
}
```

To use a subdirectory within a WebDAV share, prepend source URI with `/path/to/content`:
`https://docs.example.org/remote.php/dav/files/user/path/to/content`

By default, `ttl` is undefined and cache is never invalidated except by calling `getKeys()`, which always refetches metadata, including the 'etag' for each resource, which uniquely identifies its version. This is used to invalidate the cache of the content of each resource.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
"@azure/storage-blob": "^12.14.0",
"@planetscale/database": "^1.8.0",
"@upstash/redis": "^1.22.0",
"@vercel/kv": "^0.2.2"
"@vercel/kv": "^0.2.2",
"fast-xml-parser": "^4.2.6"
},
"peerDependenciesMeta": {
"@azure/app-configuration": {
Expand Down
Loading