grails - How to render a byte array (Blob) as image using TagLib -
grails - How to render a byte array (Blob) as image using TagLib -
how render image file (blob) stored in database using custom tag, used render logo image beingness crashed , output byte array.
this tried:
def logo = { attrs, body -> if(session?.companyid && session?.companyid != 'null'){ company company = company.findbyid(session?.companyid) if (!company || !company?.logo) { println "no response..." out <<"<img src='/cdc/static/images/logo.png' width='150' height='70' />" } else{ println "writing..." out << "<img src='" out << company?.logo out << "' width='150' height='70' />" } } else{ println "no response..." //out <<"<img src='/cdc/static/images/logo.png' width='150' height='70' />" } }
the output follows:
how can company?.logo rendered image , not byte array ?
it sounds want provide data uri, basically. you'll want like:
src="data:img/png;base64,xxx"
where "xxx" info in base64 format.
so example, using this public domain base64 library:
out << "<img src='data:img/png;base64," out << base64.encode(company?.logo) out << "' width='150' height='70' />"
grails groovy
Comments
Post a Comment