The problem is that download creates a http response with attachment
you should be able to write a function that just returns the content
of the image
def show()
  import gluon.contenttype
  response.headers['Content-Type'] =
gluon.contenttype.contenttype('.jpg')
  filename, file =
db.myimages.img_upload.retrieve( db.myimages[1].img_upload)
  return file.read()

On Jun 16, 11:09 am, Vinicius Assef <vinicius...@gmail.com> wrote:
> Hi guys.
>
> I have a table (called anuncio) with an upload field (called foto), so
> anuncio.foto is my upload field.
>
> I'm showing and linking it with this piece of code in my view :
>     {{url = URL(c='anuncios',f='download', args=['uploads', anuncio.foto])}}
>     {{=A(IMG(_src=url), _href=url)}}
>
> My /contollers/anuncios.py/download() function is the default, as seen below:
> def download():
>     return response.download(request,db)
>
> When user clicks on this image, browser shows the download dialog,
> asking him/her where to save the image.
> But I'd like to simply show the image, not present the download
> dialog. All these images will be public.
>
> How I solved it:
> 1) I entered in /myapp/static/images and created a symbolic link
> called 'uploads' pointing to /myapp/uploads.
> 2) In my view, I changed the: {{url = URL(...}} stuff by this: {{url =
> URL(c='static', f='images', args=['uploads', anuncio.foto])}}
>
> I think this isn't the best choice because I'm pointing URL() to a
> fake controller and function, and I'm counting on an external
> resource: a symbolic link in my filesystem.
>
> How would be the "web2pythonic" way to do this?
>
> --
> Vinicius Assef.

Reply via email to