Reputation: 1117
I am using @google-cloud/storage for accessing the GCS API. After enabling versioning, I am trying to fetch a specific generation of a file using the following code:
bucket.file(`${name}#${generationId}`).download({
destination
}).then(() => {
res.set({
'Content-Type': 'image/jpeg'
});
return res.status(200).sendFile(destination);
})
Where name
is the complete object name and generationId
contains the number of the generation of the file.
However, if I am executing above code within Google Cloud Functions, I am receiving the following error message:
ApiError: No such object: my-bucket/image-mxmg569kdvnby6z85mi#1522107649220516
I am sure that the file and generation exists, as I have checked it with the JSON API explorer. My guess is that @google-cloud/storage
does not support file versioning (yet), the documentation did not contain any information. Does anyone have experience with that?
Upvotes: 2
Views: 1755
Reputation: 5770
If you set options.generation
when instantiating the File object, it should work! https://github.com/googleapis/nodejs-storage/blob/4f4f1b4043c4f70ee99f051499ac62e893abdde0/src/file.js#L82
bucket.file(name, { generation: generationId })
Upvotes: 1