code: protected byte[] getFieldAsBytes(GenericRecord record, String fieldLocation) throws Exception {
      Optional<Object> bytesValue = AvroUtils.getFieldValue(record, fieldLocation);
      if (!bytesValue.isPresent()) {
        throw new Exception("Bytes value with key " + fieldLocation + " not found in the record");
      }
      ByteBuffer bb = (ByteBuffer) bytesValue.get();
      if (bb.hasArray()) {
        return bb.array();
      } else {
        byte[] payloadBytes = new byte[bb.remaining()];
        bb.get(payloadBytes);
        return payloadBytes;
      }
    }
docs: Get field value byte array
  
  @param record the input record which has the field
  @param fieldLocation a dot separated location string to the field
  @return the byte array of field value