使用 Node.js 通过名称检查 GCS 存储桶中文件的存在

使用 Node.js 通过名称检查 GCS 存储桶中文件的存在

我想知道 Google Cloud Storage 是否提供了一种有效的方法来使用 node.js 检查给定名称的文件是否存在于给定存储桶中。这种方法bucket.fileExists('someName')是理想的。如果有明显的答案,我很抱歉。任何建设性的反馈都将不胜感激。

答案1

他们补充道file.exists() 方法

const fileExists = _=>{
    return file.exists().then((data)=>{ console.log(data[0]); });
}

fileExists();
//logs a boolean to the console;
//true if the file exists;
//false if the file doesn't exist.

相关内容