MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / WebDAVFileReader

Class WebDAVFileReader

packages/filesystem/webdav/rw.ts:4–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import type { FileReader, FileWriter } from "../filesystem";
3
4export class WebDAVFileReader implements FileReader {
5 client: WebDAVClient;
6
7 path: string;
8
9 constructor(client: WebDAVClient, path: string) {
10 this.client = client;
11 this.path = path;
12 }
13
14 async read(type?: "string" | "blob"): Promise<string | Blob> {
15 switch (type) {
16 case "string":
17 return await (this.client.getFileContents(this.path, {
18 format: "text",
19 }) as Promise<string>);
20 default: {
21 const resp = (await this.client.getFileContents(this.path, {
22 format: "binary",
23 })) as ArrayBuffer;
24 return new Blob([resp]);
25 }
26 }
27 }
28}
29
30export class WebDAVFileWriter implements FileWriter {
31 client: WebDAVClient;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected