For reasons of which I'm not totally sure, I was unable to use web2py's 
download function with a particular table's upload field 
<https://groups.google.com/forum/#!topic/web2py/u60oQK-7EbM>. Consequently, 
I hacked my way around it by doing something like this:

def return_image_as_string(db, table_name, field_name, image_name):
    import base64
    _, stream = db[table_name][field_name].retrieve(image_name)
    return 'data:image/png;base64,' + base64.b64encode(stream.read())

def myfunc():
    img = IMG(..., _src = return_image_as_string(...))
    ...

Does it make sense to do this from the point of view of efficiency, 
security, functionality (i.e. will it work on all browsers?), etc...? If 
the idea is fundamentally sound, are there possible improvements to the 
above code?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to