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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---