Using web2py and Google App Engine, I create on a model file, a field to upload the image and another one to save its download URL.
Field('logotipo_marca_url', 'upload', uploadfield='logotipo_marca_blob'),
Field('logotipo_marca_blob', 'blob'),
I order to retrive the image save, I use the default download code from example application:
function download():
return response.download(request,db)
When I use the image URL inside html IMG tag, the image is displayed within HTML… but if I paste the image on browser, it will be downloaded instead open in browser.
I’ve tried to change the response headers, like “Content-type” and “Content-Disposition” but I had sucess with it.
Q1:
I need that image opens inside the browser.
Q2: And one thing else happens, the image is downloaded with the same original file name it were uploaded… I need change it and a name that I will choose. How can I do that?
Image must have
Content-Type=image/jpeg(or other relevant type: png, gif..) in order for browser to treat it like an image. Do not useContent-Disposition, this is in browsers used to declare data as downloadable file.