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

Method read

packages/filesystem/baidu/rw.ts:15–33  ·  view source on GitHub ↗
(type?: "string" | "blob")

Source from the content-addressed store, hash-verified

13 }
14
15 async read(type?: "string" | "blob"): Promise<string | Blob> {
16 // 查询文件信息获取dlink
17 const data = await this.fs.request(
18 `https://pan.baidu.com/rest/2.0/xpan/multimedia?method=filemetas&access_token=${
19 this.fs.accessToken
20 }&fsids=[${this.file.fsid!}]&dlink=1`
21 );
22 if (!data.list.length) {
23 throw new Error("file not found");
24 }
25 const resp = await fetch(`${data.list[0].dlink}&access_token=${this.fs.accessToken}`);
26 switch (type) {
27 case "string":
28 return await resp.text();
29 default: {
30 return await resp.blob();
31 }
32 }
33 }
34}
35
36export class BaiduFileWriter implements FileWriter {

Callers

nothing calls this directly

Calls 3

requestMethod · 0.45
textMethod · 0.45
blobMethod · 0.45

Tested by

no test coverage detected