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

Method createDir

packages/filesystem/baidu/baidu.ts:36–57  ·  view source on GitHub ↗
(dir: string, _opts?: FileCreateOptions)

Source from the content-addressed store, hash-verified

34 }
35
36 async createDir(dir: string, _opts?: FileCreateOptions): Promise<void> {
37 dir = joinPath(this.path, dir);
38 const urlencoded = new URLSearchParams();
39 urlencoded.append("path", dir);
40 urlencoded.append("size", "0");
41 urlencoded.append("isdir", "1");
42 urlencoded.append("rtype", "3");
43 const myHeaders = new Headers();
44 myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
45 const data = await this.request(
46 `https://pan.baidu.com/rest/2.0/xpan/file?method=create&access_token=${this.accessToken}`,
47 {
48 method: "POST",
49 headers: myHeaders,
50 body: urlencoded,
51 redirect: "follow",
52 }
53 );
54 if (data.errno) {
55 throw new Error(JSON.stringify(data));
56 }
57 }
58
59 async request(url: string, config?: RequestInit) {
60 config = config || {};

Callers

nothing calls this directly

Calls 3

requestMethod · 0.95
joinPathFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected