Upload file to file system in grails while using scaffolding to generate controllers and views -
i'm using grails 2.2.2 . in project, i'm scaffolding controllers , views domain. want upload file , store uploaded file on file system, instead of database. in db, i'm going store location of uploaded file.
i googled bit found way store uploaded file in db defining byte[] property , don't want that. please tell me how save uploaded file on file system scaffolding
you can't scaffolding. you'd have implement actual action in controller. assuming want save file in save() action:
def save() { def somefile = request.getfile("somefile") // create new file somewhere store uploaded file: def file = new file("/some/path/for/file.foo") somefile.transferto(file) }
obviously, there's better ways manage in terms of paths , doing in service, etc. that's gist , takeaway can't scaffolded.
Comments
Post a Comment