使用 Node.js 在 GCS 存储桶中按名称检查文件是否存在

Lex*_*Lex 4 node.js google-cloud-storage google-cloud-platform

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

Lex*_*Lex 9

他们添加了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.
Run Code Online (Sandbox Code Playgroud)