Hi

I tried it with Grails 1.2.0 and app-engine plugin 0.8.8 but got just
an another error:

java.lang.NoClassDefFoundError: Could not initialize class
org.apache.commons.fileupload.disk.DiskFileItem
        at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem
(DiskFileItemFactory.java:196)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest
(FileUploadBase.java:358)
        at
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest
(ServletFileUpload.java:126)
        at
org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest
(CommonsMultipartResolver.java:155)

my controller:

        def imageInstance = new Image(imageParams)
        def f = request.getFile('imageData')
        imageInstance.imageData = f.getBytes()
        Image.withTransaction {
                if(imageInstance.save(flush:true)) {
                    flash.message = "Image ${imageInstance.id} created"
                    redirect(action:show,id:imageInstance.id)
                }
                else {
                    render(view:'create',model:[imageInstance:imageInstance])
                }
        }


and domain-class:

import javax.persistence.*;
// import com.google.appengine.api.datastore.Key;

@Entity
class Image implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long id
    byte[] imageData

    static constraints = {
        id visible:false
    }

}

It seems like the multipart resolver is not replaced with the new one.
I placed the jar file into <myApplication>/lib and <GRAILS_HOME>/lib
directories.
Maybe I didn't place the jar to the right directory?
Would you like to tell more about how you got it to work?


Markus


On 2 helmi, 00:00, Sebastian Cartier <[email protected]> wrote:
> this works also for grails!
> Add the library to your lib directory and add
>     <bean id="multipartResolver"
>
> class="is.hax.spring.web.multipart.StreamingMultipartResolver">
>     </bean>
> to your applicationContext.xml
>
> For saving the image in a google blob i used the following functions:
>         @Persistent
>         Blob imageBlob
>
>         byte [] getImage(){
>                 if(imageBlob){
>                         imageBlob.getBytes()
>                 }else{
>                         null;
>                 }
>         }
>
>         void setImage(byte [] imageBytes){
>                 imageBlob = new Blob(imageBytes)
>         }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to