MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / OneDriveFileReader

Class OneDriveFileReader

packages/filesystem/onedrive/rw.ts:6–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import type OneDriveFileSystem from "./onedrive";
5
6export class OneDriveFileReader implements FileReader {
7 file: FileInfo;
8
9 fs: OneDriveFileSystem;
10
11 constructor(fs: OneDriveFileSystem, file: FileInfo) {
12 this.fs = fs;
13 this.file = file;
14 }
15
16 async read(type?: "string" | "blob"): Promise<string | Blob> {
17 const data = await this.fs.request(
18 `https://graph.microsoft.com/v1.0/me/drive/special/approot:${joinPath(this.file.path, this.file.name)}:/content`,
19 {},
20 true
21 );
22 if (data.status !== 200) {
23 throw new Error(await data.text());
24 }
25 switch (type) {
26 case "string":
27 return data.text();
28 default: {
29 return data.blob();
30 }
31 }
32 }
33}
34
35export class OneDriveFileWriter implements FileWriter {
36 path: string;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected