I currently make use of the following to upload a file to S3:
File file = new File(my_file_path);
AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(cred));
s3.putObject(new PutObjectRequest("folder", key, file));
The above works fine but I want to directly save a BufferedImage to S3 to shave a few seconds from my application but I have no clue on how to do this? This is how I currently save my image to a file:
image = new BufferedImage(rawImage.width, rawImage.height, BufferedImage.TYPE_INT_ARGB);
File file = new File(filepath);
ImageIO.write(image, "png", file);
Is there a way to do the writing directly to Amazon S3 as a stream, if so, can someone show an example?
In addition, is this a good idea? If its prone to errors, I'll stick to my current method. Any advice appreciated.