0

I'm setting up a Dataflow pipeline, in which one of the action is to get/add the metadata[User-provided metadata] of a GCS file.

In a standalone java app I used below method to get the metadata which is from StorageObject class but not finding something similar method/api in Apache Beam library. Any pointers will be really helpful.

//Below code is from StorageObject.java
com.google.api.services.storage.model.StorageObject
//.....
public java.util.Map<String, java.lang.String> getMetadata() {
     return metadata;
}
Bala
  • 45
  • 1
  • 9

1 Answers1

1

I used following code to get the metadata from GCS and it works good in DataFlow pipeline.

import com.google.cloud.storage.{BlobId, BlobInfo, Storage, StorageOptions}

val storage: Storage = StorageOptions.getDefaultInstance.getService
val blobId: BlobId = BlobId.of("bucket", "filename")
val srcMap: Map[String, String] = storage.get(blobId).getMetadata
Bala
  • 45
  • 1
  • 9