**
* 图片base64返回格式:%s1=文件后缀,%s2=Base64Utils.encodeToString(src)
*/
private static String IMG_BASE_64 = "data:image/%s;base64,%s";
public static String imgByteToBase64(byte[] src, String fileType, boolean isImg) {
if (isImg) {
String base64 = Base64Utils.encodeToString(src);
return String.format(IMG_BASE_64, fileType, base64);
}
throw new SgccException(IResponseEnum.getInstance(-1, "文件不是图片类型,无法转成对应的base64"));
}
byte数组再转base64字符串
最新推荐文章于 2024-08-01 04:41:29 发布