public static String imgToBase64StrWithPrefix(byte[] imageBytes, String formatName) {
        formatName = formatName != null ? formatName : "jpeg";
        return String.format("data:image/%s;base64,%s", formatName, CommonUtils.bytesToBase64Str(imageBytes));
    }
public static String imgToBase64StrWithPrefix ( byte [ ] imageBytes , String formatName ) { formatName = formatName != null ? formatName : "jpeg" ; return String . format ( "data:image/%s;base64,%s" , formatName , CommonUtils . bytesToBase64Str ( imageBytes ) ) ; }
将指定的图片字节数组进行Base64编码并返回

@param imageBytes 指定的图片字节数组
@param formatName 图片格式名,如gif,png,jpg,jpeg等,默认为jpeg
@return 编码后的Base64字符串