def upload():
    import cStringIO
    data=request.body.read()
    f=cStringIO.StringIO(data)
    current_filename='bla.bla' # how to you know the file extension if
you do not pass the name?
    new_filename=db.mytable.picture.store(f,current_filename)
    # do something with new_filename and data

On Sep 10, 2:40 pm, ab <adam.ba...@googlemail.com> wrote:
> I don't know uploaded file name. There is only stream of bytes to save
> in blob field.
>
> On Sep 10, 9:27 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > It depends on how you send the file. Can you send me an example?
>
> > On Sep 10, 2:19 pm, ab <adam.ba...@googlemail.com> wrote:
>
> > > Thanks. Working fine.
>
> > > I have one more question.
>
> > > When I upload file by database administration, field file contains for
> > > example following entry -
> > > picture.file.975598ae58526cda.
> > > 46697265666f785f77616c6c70617065722a706a67.png
>
> > > I want to upload files by REST. Is there function which I can use to
> > > calucate file field value as above?
>
> > > On Sep 10, 7:25 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > Please try
>
> > > >   Field('file_data','blob',default=''))
>
> > > > On Sep 10, 10:57 am, ab <adam.ba...@googlemail.com> wrote:
>
> > > > > Hi
>
> > > > >   I found issue in database administration module and blob field for
> > > > > files storage
>
> > > > >   When model is defined as below
>
> > > > >  db.define_table('picture', Field('file','upload'))
>
> > > > >   there is no problem with inserting new records using 'database
> > > > > administration'
>
> > > > > but when model is defined to store files in database as below
>
> > > > > db.define_table('picture',
> > > > >   Field('file','upload',uploadfield='file_data'),
> > > > >   Field('file_data','blob'))
>
> > > > > 'database administration' can't insert new record.
>
> > > > > I don't know if this is issue or current limitation.
>
> > > > > Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to