Skip to content
Advertisement

Tag: amazon-s3

How to write an S3 object to a file?

What’s the fastest way to write an S3 object (of which I have the key) to a file? I’m using Java. Answer While IOUtils.copy() and IOUtils.copyLarge() are great, I would prefer the old school way of looping through the inputstream until the inputstream returns -1. Why? I used IOUtils.copy() before but there was a specific use case where if I

AWS S3 Java SDK – Download file help

The code below only works for downloading text files from a bucket in S3. This does not work for an image. Is there an easier way to manage downloads/types using the AWS SDK? The example included in the documentation does not make it apparent. Thanks! Answer Instead of Reader and Writer classes you should be using InputStream and OutputStream classes:

Advertisement