You have to do it manually:

stream=open(..., 'rb')
db.photo.insert(photo=db.photo.photo.store(stream,
'filename.ext'),photo_data=stram.read())

this is because when you use insert you have to specify the field
name.

Ate the form level this is automatic.

On Sep 2, 12:17 pm, kachna <[email protected]> wrote:
> Hi once again today!
> I am trying manual upload on table with upload 
> field(book:http://web2py.com/book/default/chapter/06#Manual-Uploads). My model
> store data in database:
>
> db.define_table('photo',
>         Field('photo', 'upload', uploadfield='photo_data'),
>         Field('photo_data', 'blob')
> )
>
> this pass:
>
> db.photo.insert(photo=db.photo.photo.store(open(..., 'rb'), 'file
> name.ext'))
>
> but in database is no data. Just UUID file name in "photo" field.
>
> I checked source and store method is prepare to store file on
> filesystem only, so file data can't be in DB. I can't find method
> which upload data into DB when SQLFORM is used.
>
> Any Idea? Thx

Reply via email to