LPS-16196 Convert toByteArray into toInputStream, and reimplement toByteArray to reuse the input stream
LPS-16196 Re-add methods