Tomás Lin’s Programming Brain Dump

Flex, Grails, Facebook, iPhone and all that Jazz

Posts Tagged ‘showing images

image uploading in Grails with 5 lines of code

with 4 comments

In your domain class, define


class Something{
byte[] image
}

in your controller, call

def image= {
def something = Something.get( params.id )
byte[] image = something.image
response.outputStream << image
}

Image gets copied to the database. You can then show it by

<img src="${createLink(controller:'something', action:'image', id: something.id)}"/>

Written by Tomas Lin

April 22, 2008 at 7:40 pm