protected void prependBase64EncodedResources ( StringBuffer sb , Map < String , Base64EncodedResource > encodedImages ) { Iterator < Entry < String , Base64EncodedResource > > it = encodedImages . entrySet ( ) . iterator ( ) ; StringBuilder mhtml = new StringBuilder ( ) ; String lineSeparator = StringUtils . STR_LINE_FEED ; mhtml . append ( "/*!" ) . append ( lineSeparator ) ; mhtml . append ( "Content-Type: multipart/related; boundary=\"" + BOUNDARY_SEPARATOR + "\"" ) . append ( lineSeparator ) . append ( lineSeparator ) ; while ( it . hasNext ( ) ) { Entry < String , Base64EncodedResource > pair = it . next ( ) ; Base64EncodedResource encodedResource = ( Base64EncodedResource ) pair . getValue ( ) ; mhtml . append ( BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR ) . append ( lineSeparator ) ; mhtml . append ( "Content-Type:" ) . append ( encodedResource . getType ( ) ) . append ( lineSeparator ) ; mhtml . append ( "Content-Location:" ) . append ( encodedResource . getId ( ) ) . append ( lineSeparator ) ; mhtml . append ( "Content-Transfer-Encoding:base64" ) . append ( lineSeparator ) . append ( lineSeparator ) ; mhtml . append ( encodedResource . getBase64Encoding ( ) ) . append ( lineSeparator ) . append ( lineSeparator ) ; } mhtml . append ( BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR + BOUNDARY_SEPARATOR_PREFIX ) . append ( lineSeparator ) ; mhtml . append ( "*/" ) . append ( lineSeparator ) . append ( lineSeparator ) ; sb . insert ( 0 , mhtml . toString ( ) ) ; }
Prepend the base64 encoded resources to the bundle data