6

I'd like to know if Google Cloud Storage provides an efficient way of checking if a file with a given name exists in a given bucket with node.js. A method such as bucket.fileExists('someName') would be ideal. I apologize if there's an obvious answer. Any constructive feedback would be greatly appreciated.

Lex
  • 191
  • 1
  • 1
  • 7

1 Answers1

12

They added the file.exists() method.

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.
VictorGGl
  • 105
  • 6
Lex
  • 191
  • 1
  • 1
  • 7