* 删除文件 * 此操作幂等——删除不存在的文件也会成功 * @param path 相对于当前 basePath 的文件路径
(path: string)
| 183 | * @param path 相对于当前 basePath 的文件路径 |
| 184 | */ |
| 185 | async delete(path: string): Promise<void> { |
| 186 | try { |
| 187 | await this.client.request("DELETE", this.bucket, joinPath(this.basePath, path).substring(1)); |
| 188 | } catch (error: any) { |
| 189 | // S3 delete 是幂等的,key 不存在时也视为成功 |
| 190 | if (error instanceof S3Error && error.code === "NoSuchKey") { |
| 191 | return; |
| 192 | } |
| 193 | throw error; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * 列出当前目录下的文件 |