| 83 | } |
| 84 | |
| 85 | delete(path: string): Promise<void> { |
| 86 | const filelist = [joinPath(this.path, path)]; |
| 87 | const myHeaders = new Headers(); |
| 88 | myHeaders.append("Content-Type", "application/x-www-form-urlencoded"); |
| 89 | return this.request( |
| 90 | `https://pan.baidu.com/rest/2.0/xpan/file?method=filemanager&access_token=${this.accessToken}&opera=delete`, |
| 91 | { |
| 92 | method: "POST", |
| 93 | body: `async=0&filelist=${encodeURIComponent(JSON.stringify(filelist))}`, |
| 94 | headers: myHeaders, |
| 95 | } |
| 96 | ).then((data) => { |
| 97 | if (data.errno) { |
| 98 | throw new Error(JSON.stringify(data)); |
| 99 | } |
| 100 | return data; |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | async list(): Promise<FileInfo[]> { |
| 105 | const list: FileInfo[] = []; |