public String generateDataURI ( final InputStream inputStream , final String fileName ) throws IOException { final StringWriter writer = new StringWriter ( ) ; final byte [ ] bytes = IOUtils . toByteArray ( inputStream ) ; inputStream . close ( ) ; final String mimeType = getMimeType ( fileName ) ; // actually write generateDataURI ( bytes , writer , mimeType ) ; return writer . toString ( ) ; }
Generate the dataUri as string associated to the passed InputStream with encoding & type based on provided fileName .