AKd
AKd

Reputation: 645

How to find out whether Google storage object is live or noncurrent?

Google Storage documentation tells about Object Versioning. There are two kinds of the object versions: live and noncurrent.

gsutil allow listing both noncurrent and live versions using -a switch: https://cloud.google.com/storage/docs/using-object-versioning#list.

Also, I can list all the versions programmatically by supplying versions: true option to the Bucket.getFiles method.

However I have not found any way to programmatically find out whether a particular object version is live or noncurrent. There seems to be no property or method in the File object for this.

What is the proper way of finding this out given a File instance?

Upvotes: 2

Views: 1754

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75820

By looking at the REST API, there isn't a state for the live/noncurrent version of the objects. You have a generation number per object resource representation.

I assume that you have to apply yourselves an algorithm for this

  • Use List API (getFiles) on a single object with the version option to true
  • The highest generation is the live version, others are noncurrent
  • Except is timeDeleted is populated on the highest generation (timestamp of the live version deletion). Therefore all the version are noncurrent.

Upvotes: 3

Related Questions