| 2 | import type { FileReader, FileWriter } from "../filesystem"; |
| 3 | |
| 4 | export 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 | |
| 30 | export class WebDAVFileWriter implements FileWriter { |
| 31 | client: WebDAVClient; |
nothing calls this directly
no outgoing calls
no test coverage detected