thanks, solved by this:

    counter = 0
    for root, dirs, files in os.walk(repo_path):
        i = 10000
        for filename in files:
            path = os.path.join(root, filename)
            new_filename = 'image.file.' + str(i + counter) + '.' +
filename
            shutil.copyfile(path, upload_path + new_filename)
            imgId = db.image.insert(file = new_filename)

On 22 Ott, 16:24, mdipierro <mdipie...@cs.depaul.edu> wrote:
> assuming db.image.file.type == 'upload' you can do
>
> def process_repo():
>     for root, dirs, files in os.walk(repo_path):
>         for filename in files:
>             path = os.path.join(root, filename)
>             imgId = db.image.insert(file = db.image.file.store(open
> (path,'rb'),filename))
>
> On Oct 22, 5:02 am, Alessio <texto...@gmail.com> wrote:
>
> > Hi,
> > i have web2py application that manages images, it has a simple defined
> > database with an upload field that refers to uploaded images.
> > Thus i am able to store images inside the database using the web2py
> > provided form. But for testing needings i have an action in my default
> > controller that scans a local dir for images and has to insert them
> > inside the web2py database. This is the code:
>
> > def process_repo():
> >     for root, dirs, files in os.walk(repo_path):
> >         for filename in files:
> >             path = os.path.join(root, filename)
> >             imgId = db.image.insert(file = filename)
>
> > where file is the upload field name obviously.
>
> > This is actually inserting records in the database but when i try to
> > download (visualize) images.. the response is not found.
>
> > I think i need something like a function to store the local file in
> > web2py system before inserting it into the database. Can you help me?
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
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