Handle file upload with Deform + SqlAlchemy in Pyramid

596 views
Skip to first unread message

keesjan

unread,
May 29, 2011, 5:24:05 AM5/29/11
to pylons-discuss
Possibly a newbie question (which I am), but I'm stuck.

I try to create a file upload form to store small binary (audio) files
in a DB.

I use Deform for my form which contains a FileUploadWidget. Great. But
after this I hit a brick wall. How to pass the data from Deform
filedict into a SqlAlchemy LargeBinary?

The 'fp' attribute is a file-like object, but the LargeBinary field
(actually its handler (?!) DBAPIBinary) expects a buffer. Maybe this
is solved with elementary Python stuff, but googling for "python file
to buffer" didn't lead to any helpful examples.

Any help is much appreciated.

Kind regards,

Keesjan

keesjan

unread,
May 29, 2011, 5:54:23 PM5/29/11
to pylons-discuss
OK. It _was_ a newbie question. This link solved my problem:
http://www.java2s.com/Tutorial/Python/0240__File/Readbytesintoabuffer.htm

My apologies for taking up your precious bandwidth. ;)

Keesjan

On 29 mei, 11:24, keesjan <k.vanbunnin...@inter.nl.net> wrote:
> Possibly a newbie question (which I am), but I'm stuck.
>
> I try to create a file upload form to store small binary (audio) files
> in a DB.
>
> I use Deform for my form which contains a FileUploadWidget. Great. But
> after this I hit a brick wall. How to pass the data from Deform
> filedict into a SqlAlchemy LargeBinary?
>
> Keesjan
Reply all
Reply to author
Forward
0 new messages