Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Converting TIFF files to base64 using Java

Hi 

I have two instances where I'm converting a TIFF file before sending the data to google vision AI. Using CLI, the base64 string works fine. I get the expected response

When I use Java I'm getting a different out, which causes my API call to fail. The base64 output is different.

 

imageBytes = Files.readAllBytes(new File(fileLocation).toPath());
String imageString = Base64.getEncoder().withoutPadding().encodeToString(imageBytes);
// API response "message": "Unsupported input file format."

 

I'm looking for suggestions on how to convert a file (tiff, pdf, png) to base64 using plain Java

 

0 1 1,091
1 REPLY 1