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.