我正在使用 Node 10 和 gcs API。
试图删除一个文件夹及其所有内容,但我不知道如何。
在 API 文档中没有找到关于删除文件夹的内容。
我尝试了以下代码,该代码适用于单个文件,但不适用于整个文件夹:
const { Storage } = require('@google-cloud/storage');
const storage = new Storage({
projectId: 'my-id'
});
const bucket = storage.bucket('photos');
// Attempt to delete a folder and its files:
bucket
.file('album-1')
.delete()
.then(...)
.catch(...);
Run Code Online (Sandbox Code Playgroud)