之前遇到的小问题,记录一下,仅此而已。
代码语言:javascript复制private static String imgToBase64(String path) {
try {
HttpResponse response = HttpRequest.get(path).execute();
if ( null == response) {
throw new BizException(CosmosResultCodeEnum.BIZ_FAIL);
}
return "data:image/jpeg;base64," Base64.encodeBase64String(response.bodyBytes());
} catch (Exception e) {
throw new BuisnessException(CosmosResultCodeEnum.BIZ_FAIL);
}
}
Copyright: 采用 知识共享署名4.0 国际许可协议进行许可 Links: https://lixj.fun/archives/图片转为base64编码