On Tuesday, October 22, 2019 at 1:23:46 AM UTC-7, Ruslan Gareev wrote:
>
> try:
> controller function():
>    imgs = ['<img src="' + URL('static','images/3.jpg') + '" 
> style="max-height=100px;border-radius:7px;"/>']
>
>
>
>
<IMG> tags work great for static files.  And for files in the db that use 
the upload field type, the "app/download?obfusctatedfilename" provides a 
handy way to download the file.  (The usual way of finding 
obfuscatedfilename is to do a select() based on the original filename 
(which upload fields can also store), or a tag, or the id if you already 
have that in hand.)  You can also use that url in an <IMG> tag.

In your view,
<IMG src={{=URL("download", "obuscatedfilename")}} />
or 
{{=IMG(_src=URL("download", "obuscatedfilename"))}} 

If the file in the DB isn't in an upload field, you can use 
response.stream(filepath, 
request) or set the content type and return the read results, like 
Massimo's example in
<URL:https://groups.google.com/d/msg/web2py/iP3vSfKn-8c/UzINycmsBwAJ>.
My previous example,
<URL:https://groups.google.com/d/msg/web2py/MTJoZc1Kh6I/oYjxBn2KCQAJ>
used cStringIO, but it seems that can be skipped especially if it is an 
image file.

/dps


-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/cd2b6547-a9ea-4885-9562-d4f28f47453b%40googlegroups.com.

Reply via email to