title: Save a BufferedImage object to Amazon S3 as a file
body: <p>I currently make use of the following to upload a file to S3:</p>
  
  <pre><code>File file = new File(my_file_path);
  
  AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(cred));
  
  s3.putObject(new PutObjectRequest("folder", key, file));
  </code></pre>
  
  <p>The above works fine but I want to directly save a <code>BufferedImage</code> 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:</p>
  
  <pre><code>image = new BufferedImage(rawImage.width, rawImage.height, BufferedImage.TYPE_INT_ARGB);
  
  File file = new File(filepath); 
  
  ImageIO.write(image, "png", file);
  </code></pre>
  
  <p>Is there a way to do the writing directly to Amazon S3 as a stream, if so, can someone show an example?</p>
  
  <p>In addition, is this a good idea? If its prone to errors, I'll stick to my current method. Any advice appreciated.</p>