I have requirement to pass an image in json request and I am using javax.Base64 encoder.
I am able to encode the image to Base64 but I found that mime type "data:image/png;base64" is missing in generate encoded String.
So, my encoded String looks like below :
iVBORw0KGgoAAAANSUhEUgAAAPAAAABQCAAAAAACIqegAAABMEl**********
And, here is my simple code which I am trying with junit :
@Test
public void getBiographicPanel() {
byte[] image = bacodeGenerator.generateBarocdeImage("12345678");
System.out.println(Base64.getEncoder().encodeToString(image));
System.out.println(org.apache.commons.codec.binary.Base64.encodeBase64String(image));
assertNotNull(image);
}
How, is that any way or input parameter present in Base64 API which can we configure to generate Base64 image content with MimeType like below ?
data:image/png;base64,iVBORw0KGgoAAAANS