Package com.ibm.fhir.bucket.cos
Class CosClient
- java.lang.Object
-
- com.ibm.fhir.bucket.cos.CosClient
-
public class CosClient extends Object
Encapsulates the AmazonS3 client for interaction with IBM Cloud Object Storage (COS)
-
-
Constructor Summary
Constructors Constructor Description CosClient(Properties cosProperties)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(String bucketName, String itemName, Consumer<BufferedReader> consumer)
Read and process the object, feeding the content to the given consumer as a BufferedReader.<T> T
read(String bucketName, String itemName, Function<PushbackInputStream,T> fn)
Read the object using the given functionvoid
scan(String bucketName, String pathPrefix, Function<String,FileType> fileTyper, Consumer<CosItem> consumer)
Scan the COS bucket, feeding each returned item to the given consumervoid
signalStop()
Tell the scanner to stop.
-
-
-
Constructor Detail
-
CosClient
public CosClient(Properties cosProperties)
Public constructor- Parameters:
cosProperties
-
-
-
Method Detail
-
signalStop
public void signalStop()
Tell the scanner to stop. Can be used to get scan() to finish early
-
read
public <T> T read(String bucketName, String itemName, Function<PushbackInputStream,T> fn)
Read the object using the given function- Type Parameters:
T
-- Parameters:
bucketName
-itemName
-fn
-- Returns:
-
process
public void process(String bucketName, String itemName, Consumer<BufferedReader> consumer)
Read and process the object, feeding the content to the given consumer as a BufferedReader. We keep control of the stream, and close it when the consumer accept call returns- Parameters:
bucketName
-itemName
-consumer
-
-
scan
public void scan(String bucketName, String pathPrefix, Function<String,FileType> fileTyper, Consumer<CosItem> consumer)
Scan the COS bucket, feeding each returned item to the given consumer- Parameters:
bucketName
-fileType
- function to derive fileType from the item key valueconsumer
- target for each non-empty CosItem we find in the bucket
-
-