Nandagopal Sekar
Nandagopal Sekar

Reputation: 106

Getting the md5 hash without getting the whole file in google cloud storage

My goal is to get the object metadata without downloading the object/blob using the java api(https://cloud.google.com/storage/docs/json_api/v1/objects#resource). I am able to do it with JSON API but unable to find the equivalent for the java API.

Upvotes: 2

Views: 2921

Answers (1)

jterrace
jterrace

Reputation: 67083

storage.objects.get can return an object's data or metadata. For the Java client, one of the storage.get methods can be used to retrieve the metadata (as opposed to storage.reader which can read the data).

Once you have the result, you can get the MD5 from BlobInfo.getMd5 method.

Upvotes: 2

Related Questions