I am currently working with Google Buckets and I am having a little trouble getting a specific file.
I am currently able to get all files by doing the following:
const [files] = await bucket.getFiles();
However, I am a little confused on how to get a single file, for example, if the name of the file in the bucket is “mypicture.jpg”, do I use a prefix? Or do I use .file()?
const [file] = await bucket.getFiles({prefix: "mypicture.jpg"});
or
const [file] = await bucket.file("mypicture.jpg");
Your help would be appreciated!
Advertisement
Answer
file function can be used to access a file reference
const file = await bucket.file("mypicture.jpg");