|
Hi Folks,
I have a question with regards to type conversion. I have a domain object which can take only two different file objects. I want to store and retrieve the information from a disk location. class MyFile { String fileName String path String about } class MyBook { MyFile front MyFile back String title } Now I want to upload the front and and back of the book (which are pictures) and save it to my book. Is there way I can dynamically convert multipart object into my domain object simultaneously uploading the content and transferring it to a disk store? -- Regards, U10C11 |
|
Domain objects usually map to stored data in the database. If you want to store it both on disk and as a BLOB in the database, you may want to define an interceptor before the save closure is called that writes to the file system if the model object passes validation and change one of your stings to a byte[].
If you really just want to store the filename and path in the db (which is actually a terrible idea. What if your web admin deletes the file while you're not looking? What if the content of the file is replaced, or moved? This is why Drupal and many CMSes fail in their file management schemes.) you would have to add an HTML file upload control in the view and write the file IO logic in your save closure (where one assumes you would set the fileName and path from your server side information_.
On Mon, Jan 24, 2011 at 6:51 PM, U10C11 <[hidden email]> wrote: Hi Folks, |
|
I agree that its a bad idea to store the path in the DB.
Thank you for the suggestion. On Mon, Jan 24, 2011 at 9:27 PM, Nick Vaidyanathan <[hidden email]> wrote: Domain objects usually map to stored data in the database. If you want to store it both on disk and as a BLOB in the database, you may want to define an interceptor before the save closure is called that writes to the file system if the model object passes validation and change one of your stings to a byte[]. -- Regards, U10C11 |
| Powered by Nabble | Edit this page |
