List of usage examples for com.amazonaws.util IOUtils copy
public static long copy(InputStream in, OutputStream out) throws IOException
From source file:com.amazon.photosharing.servlets.PrivateMediaServlet.java
License:Open Source License
private void streamS3Content(String p_s3_bucket, String p_s3_file, HttpServletResponse p_resp, boolean p_no_retry) throws IOException { S3ObjectInputStream stream = ContentHelper.getInstance().downloadContent(p_s3_bucket, p_s3_file); if (stream != null) { try {/*from w w w .j a va2 s. co m*/ IOUtils.copy(stream, p_resp.getOutputStream()); } catch (IOException e) { //usually broken pipe if user cancels } finally { stream.close(); p_resp.getOutputStream().flush(); p_resp.getOutputStream().close(); } } else { try { Thread.sleep(1000); //back off. eventually consistency S3 responses.. } catch (InterruptedException e) { //why would that happen? } if (!p_no_retry) streamS3Content(p_s3_bucket, p_s3_file, p_resp, true); } }