0

Buenas tardes.

Tengo la siguiente porción de código que esta dentro de un servicio REST.

        String a = "0xFFD8FFE0.........";
        //el valor de a es un dato tipo image de SQL Server
        Blob blob2 = connection.createBlob();
        blob2.setBytes(1, a.getBytes());
        InputStream inputStream2 = blob2.getBinaryStream();

        return Response.ok(inputStream2).build();

Resultado obtenido:

introducir la descripción de la imagen aquí

3
  • ¿Qué has hecho para conseguirlo? Además, este problema pertenecería a tu repositorio de datos, el cual es indistinto si tu aplicación es REST, aplicación web, aplicación de escritorio, etc.
    – user227
    el 13 jul. 2017 a las 0:37
  • Esto me funciono el 14 jul. 2017 a las 15:35
  • String image64 = "/9j/"; ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedImage image = null; byte[] imageByte= null, imageData = null; Base64.Decoder decoder; decoder = Base64.getDecoder(); imageByte = decoder.decode(image64); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); try { image = ImageIO.read(bis); bis.close(); ImageIO.write(image, "jpg", baos); imageData = baos.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return Response.ok(imageData).build(); el 14 jul. 2017 a las 15:36

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.