Image is not getting rendered in img tag while fetching image data from database using API.

While getting data in img tag using api the data is not getting rendered instead blank data with the black background is showing up.

The view with img tag which I’m using for rendering image on my navbar is :
{ view: "label", label: "<a href='/'><img class='photo' width='100', height='50' src='/pubapi/v1/getlogo.png' /></a>", width: 200 }, using api given in src.

Also the backend code in java for same is :

            log.debug("Inside get logo");
            log.debug("routingContext  :: " + routingContext.fileUploads());
            String host = routingContext.request().host();
            String subdomain = host.substring(0, host.indexOf(".")).toLowerCase().trim();
            UserContext.set("system", "public");
            //routingContext.request().response().putHeader("Content-Type", "application/octet-stream");
            Buffer logoData = tenantService.getLogo(subdomain);
            //routingContext.request().response().write(logoData);
            routingContext.request().response()
                    .putHeader("Content-Type", "image/png")
                    //.putHeader("Content-Disposition", "form-data; name=\"image\"; filename=\"logo.png\"")
                    //.putHeader("Content-Transfer-Encoding", "binary")
                    .setStatusCode(200)
                    .putHeader("Content-Length", String.valueOf(logoData.length()))
                    .end(logoData);
        });

I’m trying to render image data stored in the database with type byte[] using API declared in src of img tag but was not getting it in an appropriate manner.

Hi,

The above label widget will work similar to the native IMG tag. So if your server-side code works for the IMG tag it will work for the label as well.