(type?: "string" | "blob")
| 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 | |
| 35 | export class OneDriveFileWriter implements FileWriter { |