In one of the APIs, S3Object
is converted to String
using Apache IOUtils using the below steps:
S3ObjectInputStream inputStream = s3Object.getObjectContent();
String streamString = IOUtils.toString(inputStream);
In the other API, when I have to convert the string back to S3ObjectInputStream
, I try the following steps, but it doesn't seem to work:
Approach 1:
String streamString = IOUtils.toString(inputStream); // --> from the 1st API
S3ObjectInputStream s3ObjectInputStream = new S3ObjectInputStream
(new ByteArrayInputStream(streamString.getBytes()), null); --> Returning an incorrect/null inputstream
Approach 2:
String streamString = IOUtils.toString(inputStream); // --> from the 1st API
InputStream sampleStream = IOUtils.toInputStream(streamString, StandardCharsets.UTF_8);
Is there any other way to convert it correctly without losing data?