Convert byte[] to Base64 string for data URI

后端 未结 5 1566
名媛妹妹
名媛妹妹 2020-12-02 16:55

I know this has probably been asked 10000 times, however, I can\'t seem to find a straight answer to the question.

I have a LOB stored in my db that represents an i

5条回答
  •  天涯浪人
    2020-12-02 17:39

    I used this and it worked fine (contrary to the accepted answer, which uses a format not recommended for this scenario):

    StringBuilder sb = new StringBuilder();
    sb.append("data:image/png;base64,");
    sb.append(StringUtils.newStringUtf8(Base64.encodeBase64(imageByteArray, false)));
    contourChart = sb.toString();
    

提交回复
热议问题