code: private static byte[] getByteArrayFromStream(final InputStream inputStream) throws IOException {
      return new ByteSource() {
        @Override
        public InputStream openStream() {
          return inputStream;
        }
      }.read();
    }
docs: Gets the byte array from the input stream containing the full data from
  that stream.
  
  @param inputStream the {@code InputStream} to get the byte array from
  @return a byte array containing all data from the input stream
  @throws IOException if the stream cannot be read