|
Hi group, i dont lie if a say that before come here asking for help i tried to find and answer.
i followed this documentation http://grails.org/doc/latest/guide/theWebLayer.html#uploadingFiles specifically here File Uploads through Data Binding, because this is what i want, because for me this solution looks easier in the situation when i could need to migrate to another database now im using the default database, i want to save an image into the database later show it in an img tag but this recomendations are not working from me. do you have any suggestion? from now thanks for your help!
|
|
Have you try this http://grails.org/Simple+Avatar+Uploader
2012/6/22 chichibek bros [via Grails] <[hidden email]> Hi group, i dont lie if a say that before come here asking for help i tried to find and answer. |
|
In reply to this post by chichibek bros
On Thu, Jun 21, 2012 at 5:43 PM, chichibek bros <[hidden email]> wrote:
Hi group, i dont lie if a say that before come here asking for help i tried to find and answer. What, specifically, isn't working for you? |
|
Hello!
I would not recommand saving the image directly in the database, but in file system. You will only save the path to the image in the database. Let me know what you need exactly, maybe I can help.
Regards On Fri, Jun 22, 2012 at 1:31 PM, Samuel Gendler <[hidden email]> wrote:
|
|
You could use a blob (image to a byte[] in a domain object), I've seen
that done before but I'd highly recommend against it! On Fri, Jun 22, 2012 at 3:03 PM, reda khyatti <[hidden email]> wrote: > Hello! > > I would not recommand saving the image directly in the database, but in file > system. You will only save the path to the image in the database. Let me > know what you need exactly, maybe I can help. > > Regards > > > On Fri, Jun 22, 2012 at 1:31 PM, Samuel Gendler <[hidden email]> > wrote: >> >> >> >> On Thu, Jun 21, 2012 at 5:43 PM, chichibek bros <[hidden email]> >> wrote: >>> >>> Hi group, i dont lie if a say that before come here asking for help i >>> tried to find and answer. >>> >>> i followed this >>> documentation http://grails.org/doc/latest/guide/theWebLayer.html#uploadingFiles specifically here >>> File Uploads through Data Binding, >>> because this is what i want, because for me this solution looks easier in >>> the situation when i could need to migrate to another database now im using >>> the default database, i want to save an image into the database later show >>> it in an img tag >>> >>> but this recomendations are not working from me. do you have any >>> suggestion? >> >> >> What, specifically, isn't working for you? >> >> > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by chichibek bros
No idea what your error is, but for byte[ ] blobs try adding this to your domain class:
static mapping = { blobColumn type:'org.hibernate.type.MaterializedBlobType' .... } It was necessary for me to do this for an Oracle db; not sure about other dbs. |
|
In reply to this post by 0coco0
On Fri, Jun 22, 2012 at 7:03 AM, reda khyatti <[hidden email]> wrote:
That's really a context-sensitive decision. It makes a lot of sense to store the image data in the database itself for some applications. It depends on how efficiently your database can handle it, and the nature of your application - It can be difficult to distribute image files to a large cluster of webservers such that an fs path is consistent, backups of the image dir(s) have to be kept in sync with backups of the database so that db restores will have consistent image data, any non-webserver hosts which also use the database and need access to the images have to have filesystem-level access to the images, etc. Yes, in most cases, it is pretty easy to make an argument for storing image data externally to the database, but it isn't at all difficult to think of circumstances where that wouldn't be true.
|
|
In reply to this post by jphiloon
thanks for answer, i did not give you enough information, i going to paste the structure and the error message
domain - - - - - - - package biblio class Library { String name String slogan String address byte [] logo Date dateCreated static constraints = { name(unique:true,blank:false) slogan(nullable:true) address(nullable:true) logo(nullable:true) } static mapping = { logo column:'logo', sqltype:'blob' } String toString() { name } static hasMany = [user:User] } gsp - - - - - - <g:uploadForm action="updateImage"> <g:hiddenField name="id" value="${params.id}"/> <input type="file" name="logo"> <br> <g:submitButton name="send" value="${message(code:'biblio.upload')}"/> </g:uploadForm> controller - - - - - - def updateImage() { //def libraryInstance = new Library(params) def libraryInstance = Library.get(params.id) libraryInstance.properties['logo'] = params.logo flash.message = (libraryInstance.save(flush:true)) ? message(code:'biblio.success') : message(code:'biblio.error') if(library.hasErrors()) { println library.errors } redirect(action:'image') } error message - - - - - - - - -
thanks again. 2012/6/22 jphiloon <[hidden email]> No idea what your error is, but for byte[ ] blobs try adding this to your |
|
In reply to this post by ideasculptor
I think, in most cases, it is easier to solve the distributed file system problem than the problems inherent in binary data stored in the database.
All decisions are context-sensitive, but following general principles can help you make the right decision in many contexts. My opinion of the general case is that there are many people who have worked hard on behalf of many more people to make a network-shared storage system work. There are less people who've worked on making your particular database implementation capable of storing images effectively. In general, many developers agree that storing images outside of the database is the best practice unless you have some really good reason not to do it this way. I've never really heard a good reason. Nathan Wells On Fri, Jun 22, 2012 at 11:54 AM, Samuel Gendler <[hidden email]> wrote:
|
|
In reply to this post by chichibek bros
You need to put : enctype="multipart/form-data" in your form declaration
On Jun 23, 2012, at 2:59 AM, chichibek bros wrote: thanks for answer, i did not give you enough information, i going to paste the structure and the error message |
|
thanks you all for your help the code is now working, i followed didinj recomendation of using http://grails.org/Simple+Avatar+Uploader. Thanks
2012/6/22 Akira Ikeda <[hidden email]>
|
| Powered by Nabble | Edit this page |
