private void sendFile(InputStream in, URLConnection conn) throws IOException { conn.connect(); OutputStream out = conn.getOutputStream(); try { StreamUtils.copyStream(in, out, IO_BUFFER_SIZE); } finally { out.close(); } }