Results 1 to 6 of 6

Thread: Insert a picture (blob) into a SpringRoo project

  1. #1

    Default Insert a picture (blob) into a SpringRoo project

    Dear user,
    I'm new to Spring Roo and I was creating a small project following the simple instructions given in the reference doc.
    Now, what I would like to do is to allow the application to upload into the DB picture files (jpg, bmp, ...) and not only to upload data like strings, or integers.
    Does anybody knows how to do it?

    To be more clear:
    - In the context of the project of the pizza shop, suppose that the administrator of the application wants:
    1. to be able to upload on his DB the picture of the various pizzas;
    2. that the customers that access the application see the pictures of the various pizzas when accessing the page for the order.

    Thanks for your help

  2. #2
    Join Date
    Sep 2010
    Posts
    5

    Default Insert a picture (blob)/ Upload an image and display the same

    I too have a similar requirement and am looking for a solution. Anybody got any leads...?

    Thanks
    Ratish S

  3. #3
    Join Date
    Dec 2007
    Location
    Stockholm, Sweden
    Posts
    190

    Default

    I don't know if file uploading support is in the queue or not, but I dont see an option right now.

    You can look into file uploading part in the spring manual. This is where you will have to learn how spring controllers and validators work.
    Shahzada Hatim
    @geoaxis/twitter
    http://hatimonline.com

  4. #4
    Join Date
    May 2010
    Posts
    10

    Default field other --fieldName actualfile --type java.io.File

    I have similar requirements. In the roo shell I typed:

    Code:
    field other --fieldName actualfile --type java.io.File
    The generated .java RooEntity correctly includes the "actualFile" with its appropriate type:

    Code:
    private File actualfile;
    However, the generated create.jspx uses a field:input tag instead of creating a file upload mechanism. I manually set render to false and z to user-managed and decided to write in a file upload box:

    Code:
    <field:input render="false" field="actualfile" id="c_com_blah_Attachment_actualfile" z="user-managed"/>
    
    <input type="file" name="actualfile" size="50"> </input>
    It seems to save at least the filename with the entity. I'm not yet sure if it is persisting the file contents to the database or if there is a mechanism I can later allow downloading of the file.

    Will let you know if I find anything.

  5. #5
    Join Date
    May 2010
    Posts
    10

    Default Possible solution

    Someone else asked a similar question in 2008:

    http://forum.springsource.org/showth...e#pos t249115

    This page should hold your answers:

    http://static.springsource.org/sprin...#mvc-multipart

  6. #6
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Lightbulb Use the search, Luke

    Another thread about the same topic, with further details:

    http://forum.springsource.org/showthread.php?t=84286
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •