How can I encode a ByteArrayInputStream from Java in React as a Blob or BASE64?
java.io.ByteArrayInputStream@584e2317
My Java Code:
Connection con = DriverManager.getConnection(url, props);
final PreparedStatement stmt = con.prepareStatement("SELECT * FROM \"sg_Images\".\"Images\" ");
ResultSet rs = stmt.executeQuery();
JSONArray array = new JSONArray();
while (rs.next()) {
JSONObject obj = new JSONObject();
obj.put("Bild", rs.getBinaryStream("foto"));
obj.put("Datum", rs.getDate("datum"));
array.put(obj);
}
response.setContentType("application/json");
ServletOutputStream out = response.getOutputStream();
out.print(array.toString());
out.flush();
out.close();
rs.close();
stmt.close();
con.close();