Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Img to display Binary images

    Hi Support,

    I am trying to display image from Rest APi into Img widget.

    Img image=new Img();

    image.setSrc("data:image/jpeg;base64,"+rec.getAttribute("imageFile"));


    I am getting below error

    GET data:image/jpeg;base64,_ ... net::ERR_INVALID_URL

    Server code:

    if (resp.isSuccessful()) {



    Map<String, Object> map=new LinkedHashMap<String, Object>();

    map.put("imageFile", Base64Utils.toBase64(resp.body().bytes()));

    response.setData(map);

    I am getting right document to implement this.

    Could you please guide me right documentation or help how should I proceed with

    Thanks,
    Revan

    #2
    Using "data:" URL with an Img component is fine and known to work, so the problem is that the data is wrong. But we don't have the data - you will need to look at it.

    A good approach would be to log the final URL you have assembled and then test that URL directly (for example, with plain HTML).

    Once the data is correct, the SmartGWT component will also work.

    Comment


      #3
      Thanks for youe suggestion. Something wrong in Base64Utils Base64 conversion. I used below java.util.Base64 and it is working now

      Base64.getEncoder().encodeToString(resp.body().bytes());

      Comment


        #4
        Could you please suggest the best way to display video file from Rest API?

        Comment


          #5
          This requires choosing amongst several possible video players, some free some commercial. That is best asked about on other forums.

          Once you have settled on a player, the DOM Integration overview gives you information on how to embed it in SmartClient, and the docs for the player with teach you how to deliver the data for it.

          Comment

          Working...
          X