Reputation: 371
I enabled versioning and accessed versions of a single json file using gsutil on a Firebase storage bucket. I am now searching how to retreive versions of that file using cloud functions and eventually allow users to get back an older version of their work if needed. I did not find any documentation on how to list versions of a file with a cloud function. Is that possible? Thank you!
Upvotes: 2
Views: 767
Reputation: 600126
From within Cloud Functions you'll access Cloud Storage through the Firebase Admin SDK for Node.js, which contains a very thin wrapper around the regular Node.js SDK for Cloud Storage.
It looks like you can pass in a versions
parameter to the getFiles
method.
It should be something like:
const result = await bucket.getFiles({ versions: true })
result.files.forEach(file => {
console.log(file.name);
});
Upvotes: 2