How to read bytea image data from PostgreSQL with JPA?

后端 未结 5 965
离开以前
离开以前 2020-12-31 08:56

I have PostgreSQL database and there is column \'image\' with datatype \'bytea\'. I cannot modify columns or database configurations. JPA annotated POJO contains followign m

5条回答
  •  太阳男子
    2020-12-31 09:48

    I am adding complete code which may be useful for others (skipping try/catch),

    String base64EncryptedImage = new String(image);
    decoded = org.apache.commons.codec.binary.Base64.decodeBase64(base64EncryptedImage);
    ImageOutputStream out = new FileImageOutputStream(new File("D://abc.png"));
    out.write(decoded);
    out.close();
    

提交回复
热议问题