Wednesday, 15 July 2015

gorm - Trouble uploading photo Grails -


I am following the Grails book in action Section 5.5 is an example of how to upload a photo in a user profile. Nothing complicated:

domain

  class profile {static belongsTo = user byte [] photo string fullname string bio string home page string email String Timezone String Country String jabberAddress string toString () {"Perfil para $ {fullName} ($ {id})"} Fixed constraints = {full name (faucet: true) Bio (faucet: true, maximum size: 1000) Homepage (Null: true, url: true) Email (null: true, email: true) photo (f): Country (faucet) True: time zone (tapable: true) jabberAddress (nullable: true, email: true)}   

}

Use profile and image controller code in the source While doing this, I am trying to upload a picture of this error (less than 10kb size):

The price for the column is too long "Photo Binari (255)"

I To accept a large byte [], you have tried several ways to change the definition of the column, including:

1) In the shortage of profiles, maxSize Setting: 1024 * 200 2) In profile mapping, setting the photo type: "Byte []", Length: 1024 * 200

The mapping of the t I have tried different combinations. SqlType: byte | Byte [] | Blob | Binary but either value is too long (for byte []) or other type (e.g., blob):

[B can not be cast on java.sql.blob

Please advise. Thanks!

While testing this, it was not working for me. I did not take any advantage of all static mapping and other answers. (Auto-generated) line at the top of the controller

@ Transaction (read only = true)

I was caught. Setting it to false has fixed the problem

To open these problems, insert a temporary failOnError: true in the method of saving One quick move i.e. domainObject.save (failOnError: true)

I was normally using a service with writing access to save this image.

No comments:

Post a Comment