Home > Net >  How do I obtain meta data from GCP bucket objects like author, latest version, Gsuite URI, etc?
How do I obtain meta data from GCP bucket objects like author, latest version, Gsuite URI, etc?

Time:01-05

I am using the java GCP SDK and want to save some information about an object to a postgreSQL table right after creating it. I have found methods using the Blob type and various getter methods for that type but there are more that I need such as URI, author, last updated, latest author, and many more. Is there somewhere I can see a list of all available methods to get this type of data?

I have tried getting the URI by a few different methods and have ended up using the method below

String gUri = blob.getSelfLink();
System.out.println("Gsuite URI: " URI.create(gUri));

This method returns a regular URL not a URI and then furthermore I would have to parse it and add a few thigs. Is there a way to get the URI directly from google?

CodePudding user response:

Looking at the Java class Blob we seem to find that it extends BlobInfo which contains a lot of properties including:

  • getOwner() - The owner of the blob.
  • getSelfLink() - The URL of the blob.
  • getUpdateTimeOffsetDateTime() - The last update time.
  • getGeneration() - The current generation (version) of the blob.

As for the identity of a Blob ... it should be composed of two parts ... the bucket name as returned by getBucket() and the blob name as returned by getName().

  • Related