I need to store a file in the database using Grails. So, do you know how I can do that? Which data type should I use in the domain class (byte[] might be a solution)?
See Chapter on Uploading Files in the Grails User Guide. It is also possible to use a java.sql.Blob as type for the binary content (which would be preferable when dealing with huge files).
alternatively, store the file on disk, and store the path to it in the database. it is generally faster to access that file on disk than in a db. but of course, that really just depends on your needs in the app. But be aware of this alternative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With