How to retrieve partial S3 object values by key

1.1k Views Asked by At

Given an S3 bucket called my-bucket that includes a bucket with key named my-object, is it possible to retrieve values from the object if the object value consists of a list of key/value pairs?

i.e. if my-object contains a file with the following key/value pairs:

foo: 20, 
bar: 54, 
baz: 12

Is it possible to just retrieve the value of 'foo' by its key using the SDK for Java?

1

There are 1 best solutions below

0
On BEST ANSWER

You could use Amazon S3 Select to parse the values.

However, the format of your file isn't great because:

  • Some lines have a comma, others do not
  • It has excess spaces in the file

Let's say you had this format instead:

foo:20
bar:54
baz:12

You could then query it with S3 Select, using the colon as a separator:


Amazon S3 Select


To do this in Java, see: Selecting Content from Objects Using the SDK for Java - Amazon Simple Storage Service