[appengine-java] Re: Spring MVC - File upload problem

2010-03-12 Thread amit
Is there any demo in spring mvc also ?

On Mar 2, 7:22 am, yjun hu itswa...@gmail.com wrote:
 hi, i got a demo here.http://hapeblog.appspot.com/blog.shtml?id=2002

 On Tue, Mar 2, 2010 at 4:36 AM, Sebastian Cartier 
 sebi.cart...@gmail.comwrote:



  Hi
  my first solution i wrote isn't working any more. I had to add

  beans = {

  multipartResolver(is.hax.spring.web.multipart.StreamingMultipartResolver)
  }

  to /grails-app/conf/spring/resources.xml
  Now it works again

  @Markus: you can not use byte-arrays with google app engine. You have
  to use blobs! See my previous solution.
  I put the library in myApplication/lib

  On 2 Feb., 03:08, Markus Paaso markus.pa...@gmail.com wrote:
   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 sebi.cart...@gmail.com 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
  google-appengine-j...@googlegroups.com.
  To unsubscribe from this group, send email to
  google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.

 --
 dream or truth

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Spring MVC - File upload problem

2010-03-01 Thread Sebastian Cartier
Hi
my first solution i wrote isn't working any more. I had to add

beans = {
 
multipartResolver(is.hax.spring.web.multipart.StreamingMultipartResolver)
}

to /grails-app/conf/spring/resources.xml
Now it works again

@Markus: you can not use byte-arrays with google app engine. You have
to use blobs! See my previous solution.
I put the library in myApplication/lib

On 2 Feb., 03:08, Markus Paaso markus.pa...@gmail.com wrote:
 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 sebi.cart...@gmail.com 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Spring MVC - File upload problem

2010-03-01 Thread yjun hu
hi, i got a demo here.
http://hapeblog.appspot.com/blog.shtml?id=2002

On Tue, Mar 2, 2010 at 4:36 AM, Sebastian Cartier sebi.cart...@gmail.comwrote:

 Hi
 my first solution i wrote isn't working any more. I had to add

 beans = {

 multipartResolver(is.hax.spring.web.multipart.StreamingMultipartResolver)
 }

 to /grails-app/conf/spring/resources.xml
 Now it works again

 @Markus: you can not use byte-arrays with google app engine. You have
 to use blobs! See my previous solution.
 I put the library in myApplication/lib

 On 2 Feb., 03:08, Markus Paaso markus.pa...@gmail.com wrote:
  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 sebi.cart...@gmail.com 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
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.




-- 
dream or truth

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Spring MVC - File upload problem

2010-02-01 Thread Viðar Svansson
Hi

You need the jar file, you can download it from:
http://cloud.github.com/downloads/pjesi/springextras/springextras-1.1.jar

Hope that helps,
Viðar

2010/2/1 java rohit82.j...@gmail.com:
 Hello

 I am also using spring with appengine  I want to store a image into
 datastore. I have written same code
     bean id=multipartResolver

 class=is.hax.spring.web.multipart.StreamingMultipartResolver
     /bean

 But when I compile then I got error java.lang.ClassNotFoundException:
 is.hax.spring.web.multipart.StreamingMultipartResolver what I should
 do???

 Thanks in advance


 On Jul 5 2009, 2:06 pm, Viðar Svansson vidarsv...@gmail.com wrote:
 Hi
 Here is my configuration using StreamingMultipartResolver in my AppEngine
 MVC application.

 In my servlet context file:

     bean id=multipartResolver
           class=is.hax.spring.web.multipart.StreamingMultipartResolver
     /bean

 Then in my model:

     private MultipartFile picture;
     // getters and setters

 And finally in the contoller:

     public String uploadPicture(@ModelAttribute(picture) Picture picture)
  {
         MultipartFile file = picture.getPicture();
         byte[] rawData = file.getBytes();
         // ...

 Hope this helps.
 Viðar

 On Thu, Jul 2, 2009 at 11:30 PM, zee zenma...@gmail.com wrote:

  Is there any example on how to use StreamingMultipartResolver in
  Spring MVC based web application
  (actually grails) like sample xml file configuration settings to
  override default spring behaviour?

  I am facing the same problem using google app engine because the
  framework based on Spring MVC
  uses spring file uploads for multipart form requests.

  On Jun 25, 5:45 pm, Viðar Svansson vidarsv...@gmail.com wrote:
   Hi
   Check outhttp://github.com/pjesi/springextras

   You can use is.hax.spring.web.multipart.StreamingMultipartResolver
   I am still working on this so watch for updates.

   Cheers,
   Viðar

   On Mon, Jun 22, 2009 at 5:06 AM, hu itswa...@gmail.com wrote:
i got problem when upload file with MVC, and i wanna to know how did u
implement this ?

On May 13, 5:05 am, pjesi vidarsv...@gmail.com wrote:
 Hi

 CommonsMultipartResolver does write to the filesystem, which is not
 what Google wants. I'm working on a special MultipartResolver for the
 appengine to resolve this issue. Let me know if you are interested.

 Cheers
 Viðar

 On Apr 20, 9:25 pm, Arjan huij...@gmail.com wrote:

  Hi all,

  I am creating a form that allows the user touploadan image. I use
  Spring MVC. I have configured the mulipart resolved as follows:

  bean id=multipartResolver

  class=org.springframework.web.multipart.commons.CommonsMultipartResolver
          property name=maxUploadSize value=200 /
  /bean

  However, this results in an exception because it tries to write a
  temp
  file. I know the Commons FileUploadlibrary used support streaming
  without actually creating a temp file. Can someome tell me how I
  can
  configure this in Spring MVC?

  Thanks in advance!

  Arjan



-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Spring MVC - File upload problem

2010-02-01 Thread Sebastian Cartier
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Spring MVC - File upload problem

2010-02-01 Thread Markus Paaso
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 sebi.cart...@gmail.com 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.