<img src="data:image/jpeg;base64,${createLink(controller:'Photo', action:'showEncoded', id:"${PhotoInstance.id}")}" width='300' />
I'm just starting out with grails and this is my first question on Stackoverflow. My controller returns an image encoded in base64 but the above code in gsp complains that there are errors in the image.
The domain class Photo stores the JPEG image in
byte[] imagePhoto
and saved as binary
The showEncoded method is defined in my controller and encodes imagePhoto as a base64 string, returning it to the requested GSP.
def showEncoded(Photo DBPhotoInstance) {
String encoded = DBPhotoInstance.imagePhoto.encodeBase64().toString()
response.outputStream << encoded
response.outputStream.flush()
}
I've also checked to make sure the image is a JPEG file. Any help, direction or guidance thanks!