Reading from S3

  • Reading from S3 looks similar
  • You'll need to read the file as an input stream which may be annoying if you want a String
GetObjectRequest request = GetObjectRequest.builder()
    .bucket("rk0")
    .key("hello.txt")
    .build();
var inputStream = this.s3Client.getObject(request);
Scanner s = new Scanner(inputStream).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
return result;

22 / 23