[GAE] FileUpload in the Siena CRUD admin generator

55 views
Skip to first unread message

Nicolas

unread,
Jan 8, 2011, 5:11:20 PM1/8/11
to play-framework
Hello,

I use GAE and siena-crud for my Play! application. Do you know how to
have a FileUpload field in the admin controller of my model class (see
below)? How to save the file to GAE using a Blob column type? Is there
a special method that need to be overrided in the controller?

public class Image extends SienaSupport {
@Id(Generator.AUTO_INCREMENT)
public Long id;

@Column("title")
@Max(50)
@NotNull
public String title;

@Column("imageFile")
public Blob imageFile;
}

Thanks for your replies.

Pascal Voitot Dev

unread,
Jan 8, 2011, 5:21:57 PM1/8/11
to play-fr...@googlegroups.com
The automatic mapping doesn't exist for Blob yet (In fact, we are working on it at the current time in Siena)...

In your case, do you want the blob to be managed by the CrudSiena or do you manage it by yourself in your controller?

Pascal


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.


Nicolas

unread,
Jan 8, 2011, 6:55:28 PM1/8/11
to play-framework
Hello Pascal,

I would like to manage it by myself in the controller ; is there a
solution ?

Thanks

On 8 jan, 23:21, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:
> The automatic mapping doesn't exist for Blob yet (In fact, we are working on
> it at the current time in Siena)...
>
> In your case, do you want the blob to be managed by the CrudSiena or do you
> manage it by yourself in your controller?
>
> Pascal
>
> On Sat, Jan 8, 2011 at 11:11 PM, Nicolas <nicolas.p...@gmail.com> wrote:
> > Hello,
>
> > I use GAE and siena-crud for my Play! application. Do you know how to
> > have a FileUpload field in the admin controller of my model class (see
> > below)? How to save the file to GAE using a Blob column type? Is there
> > a special method that need to be overrided in the controller?
>
> > public class Image extends SienaSupport {
> >        @Id(Generator.AUTO_INCREMENT)
> >        public Long id;
>
> >        @Column("title")
> >        @Max(50)
> >        @NotNull
> >        public String title;
>
> >        @Column("imageFile")
> >        public Blob imageFile;
> > }
>
> > Thanks for your replies.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > play-framewor...@googlegroups.com<play-framework%2Bunsu...@googlegroups.com>
> > .

Pascal Voitot Dev

unread,
Jan 8, 2011, 7:07:13 PM1/8/11
to play-fr...@googlegroups.com
On Sun, Jan 9, 2011 at 12:55 AM, Nicolas <nicola...@gmail.com> wrote:
Hello Pascal,

I would like to manage it by myself in the controller ; is there a
solution ?

I think I misunderstand because my solution is really too basic :)

Can't you just do in your controller:
1) retrieve the byte[] corresponding to your file from the file
2) Blob imgBlob = new Blog(myimgbytes);
3) Image img = new Image();
img.imgBlob = imgBlob
...

img.insert();

Are you speaking about the CRUD controller or one of the controllers you coded by yourself for your app?
Do you want to enhance the CRUD controller with blob management?

Pascal


To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

Nicolas Pied

unread,
Jan 9, 2011, 2:45:26 AM1/9/11
to play-fr...@googlegroups.com
Yes, I would like to enhance my CRUD controller so that it can save the file into the database. But I do not know the method to override. 

Thanks

Nicolas

Pascal Voitot Dev

unread,
Jan 9, 2011, 5:41:22 AM1/9/11
to play-fr...@googlegroups.com
On Sun, Jan 9, 2011 at 8:45 AM, Nicolas Pied <nicola...@gmail.com> wrote:
Yes, I would like to enhance my CRUD controller so that it can save the file into the database. But I do not know the method to override. 


I'm going to think a bit about the easiest way to do that...
Wait a second :)
 

Pascal Voitot Dev

unread,
Jan 9, 2011, 8:41:49 AM1/9/11
to play-fr...@googlegroups.com
Read my last mail about crudsiena module v1.4.
I did a quick workaround so that CrudSiena manages GAE Blob with Play.

regards
Pascal
Reply all
Reply to author
Forward
0 new messages