I have a file in Amazon S3
in bucket ABCD
. I have 3 objects ("folderA/folderB/folderC/abcd.csv")
which are folders and in the final folder I have a .csv
file (abcd.csv)
. I have used a logic to convert it to JSON
and load it back into another file which is a .txt
file in the same folder ("folderA/folderB/folderC/abcd.txt")
. I had to download the file locally in order to do that. How would I read the file directly and write it back to the text file. The code which I have used to write to a file in S3 is below and I need to read a file from S3.
InputStream inputStream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_16));
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(json.length());
PutObjectRequest request = new PutObjectRequest(bucketPut, filePut, inputStream, metadata);
s3.putObject(request);