yes but it assumes 1) you know which table and field 2) no authentication. While the idea is general the implentation is specific. As you can see, it can be done in a few lines.
The current mechanism that uses the download() is more general and should be preferred. On Feb 1, 3:19 am, pistacchio <[email protected]> wrote: > hi massimo, > thanks for the suggestion, i'll try it as soon as i can. shouldn't > this be added to the framework as a standard feature? i think > retrieving images by their url is a common task. > > On Jan 31, 8:28 pm, mdipierro <[email protected]> wrote: > > > I would do: > > > def show(): > > import os > > response.headers['Content-Type']='image/jpeg' > > img = db(db.images.id == request.args[0]).select().first() or > > redirect('somewhere') > > return response.stream(open(os.path.join > > (request.folder,'uploads',img.image),'rb')) > > > On Jan 31, 12:20 pm, pistacchio <[email protected]> wrote: > > > > well, i've done, but it seems more like a hack: > > > > def show(): > > > response.headers['Content-Type']='image/jpeg' > > > img = db(db.images.id == request.args[0]).select()[0] > > > import os > > > return response.stream(open(os.getcwd() + '/applications/' + > > > request.application + '/uploads/' + img.image, 'rb')) > > > > this allows me to get my jpg images > > > throughhttp://mysite/myapp/images/show/4 > > > > On 31 Gen, 17:44, pistacchio <[email protected]> wrote: > > > > > so, if if i got it correctly, > > > > wouldn'thttp://myhost/myapp/mycontrol/download/4 > > > > return my image with id 4? this is what i want, but i get a 404 > > > > instead.. > > > > > On 31 Gen, 17:33, mdipierro <[email protected]> wrote: > > > > > > This code > > > > > > {{=URL(r=request, f='download', args= IMAGE)}} > > > > > > simply generates > > > > > > /<app>/default/download/<filename> > > > > > > prepend http://<hostname> > > > > > > and you get a static URL. > > > > > > Within the app itself you should use the {{=URL(..)}} function because > > > > > the app may be renamed and because it may be behind routes. When your > > > > > app is published online you can use the static link to reference the > > > > > download action from other apps. > > > > > > On Jan 31, 10:27 am, pistacchio <[email protected]> wrote: > > > > > > > hi! > > > > > > i've seen that i can retrieve uploaded images with > > > > > > > {{=URL(r=request, f='download', args= IMAGE)}} > > > > > > > coupled with the standard "download" method. > > > > > > > now, if i want to statically save a reference to the image (like > > > > > > saving the string "<img src=/myapp/mycontroller/download/ > > > > > > mycontroller.imagexxxxxxxxxxxxxxxx" etc, how to do that? > > -- 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.

