Normally if you have

<img width="200px" src="https://www.google.com/images/srpr/logo4w.png"; />

This instructs your browser to download and show the image logo4w.png.
In your case 

<img width="200px" src="{{=URL('download', args=image.file)}}" />

works the same way but the URL is not

https://www.google.com/images/srpr/logo4w.png

but

/<app>/<controller>/download/<image.file>

>From the point of view of the server the image is "downloaded" and 
visualized (is it not?).
What you expect is your browser to take a different action and save the 
image in your Downloads folder. That would be a client-side action and it 
must be triggered by user interaction or coded into the HTML with JS.

Did I answer the question?


On Thursday, 18 July 2013 02:53:49 UTC-5, REM wrote:
>
> It seems that I am trying to understand exactly what the "download" action 
> is intending to do, because I thought that it would provide some sort of a 
> method/link/URL for a visitor to download the uploaded image currently 
> being displayed, and that this method/link/URL would have something to do 
> with the display of the uploaded image on the show.html page (such as a 
> traditional image link of the type you responded with). If that is what is 
> supposed to happen, then I am getting a different result. The app is only 
> displaying the uploaded image via the show.html page and no apparent way to 
> ever "download" it with the download action.
>
> P.101 of the 5th edition manual states:
>
> *The "download" action expects a filename in request.args(0), builds a 
> path to the location where that file is supposed to be, and sends it back 
> to the client.*
>
> I was only able to trigger this behavior by sending the download action 
> the expected filename *manually*. I did this by looking up the filename 
> which the uploaded image had been given in 
> /applications/images/uploads/<filename>, then I sent this filename to the 
> download action by pointing the browser to
>
> http://localhost....(etc)/images/default/download/<filename>
>
> At this point, sure enough, the browser opened up a standard download 
> window and I was able to download the uploaded image as I expected the 
> download action to behave from the start. The point is that I saw no other 
> means of getting this action to trigger because, unless I have mistyped 
> something in the above quoted app code from the manual, the images app 
> never triggers the download action from show.html or elsewhere. It appears 
> to never send an uploaded image filename to the download action in any 
> request from the show.html page (or anywhere else) such that the browser 
> starts a standard download of the uploaded image as expected - and as I was 
> able to accomplish manually.
>
> Therefore, I was wondering if I had found a bug, or mistyped something, or 
> maybe I'm just not seeing something which is obvious to others. 
>
> I don't presently see how the download action operates automatically via 
> the actions described in the code for the images app, but I can get the 
> download action to *function *by doing something manually which the 
> manual seems to be saying should be happening automatically by some other 
> means. The only means I could see for it to happen was in the manual's code:
>
> <img width="200px"
>      src="{{=URL('download', args=image.file)}}" />
>
> But it doesn't seem to be doing anything for me.
>
> Thanks very much for your assistance. I appreciate it.
>
>
>
>
> On Thursday, July 18, 2013 3:14:41 AM UTC-4, Massimo Di Pierro wrote:
>>
>> I am not sure I fully understand. Are you trying to do this?
>>
>> <a href="{{=URL('download', args=image.file)}}"><img width="200px" 
>> src="{{=URL('download', 
>> args=image.file)}}" /></a>
>>
>>
>>
>> On Thursday, 18 July 2013 01:20:48 UTC-5, REM wrote:
>>>
>>> Hello, folks.
>>>
>>> I started back at the top of the manual again and I am understanding 
>>> much more by progressing slowly and with copious notes. So far, so good. 
>>>
>>> However, I have come across a bit of a puzzling issue with the latter 
>>> part of the "images" tutorial. After creating the dbases, uploading some 
>>> images via appadmin, and then adding the app's core in default.py:
>>>
>>> def index():
>>>     images = db().select(db.image.ALL, orderby=db.image.title)
>>>     return dict(images=images)
>>>
>>>
>>> def show():
>>>     image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
>>>     db.post.image_id.default = image.id
>>>     form = SQLFORM(db.post)
>>>     if form.process().accepted:
>>>         response.flash = 'your comment is posted'
>>>     comments = db(db.post.image_id==image.id).select()
>>>     return dict(image=image, comments=comments, form=form)
>>>
>>>
>>> def download():
>>>     return response.download(request, db)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> And then creating the default/index.html:
>>>
>>> {{extend 'layout.html'}} 
>>> <h1>Current Images</h1> 
>>> <ul> 
>>> {{for image in images:}} 
>>> {{=LI(A(image.title, _href=URL("show", args=image.id)))}} 
>>> {{pass}} 
>>> </ul>
>>>
>>>
>>>
>>>
>>> And finally, the default/show.html:
>>>
>>> {{extend 'layout.html'}}
>>> <h1>Image: {{=image.title}}</h1>
>>> <center>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>> </center>
>>> {{if len(comments):}}
>>>     <h2>Comments</h2><br /><p>
>>>     {{for post in comments:}}
>>>         <p>{{=post.author}} says <i>{{=post.body}}</i></p>
>>>     {{pass}}</p>
>>> {{else:}}
>>> <h2>No comments posted yet</h2>
>>> {{pass}}
>>> <h2>Post a comment</h2>
>>> {{=form}}
>>>
>>>
>>>
>>>
>>>
>>> When the app is called, it behaves as expected in every instance with 
>>> one exception: I was figuring that, based on:
>>>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>>
>>>
>>>
>>> When the image was displayed in the show.html view, that maybe it would 
>>> be tagged with an embedded download link such that passing the mouse over 
>>> the image would indicate a link and then clicking the image would trigger a 
>>> download action to download the image. This does not occur. The app just 
>>> displays the uploaded image with no apparent way to download it (aside from 
>>> the usual right-click browser options). In fact, in looking at the app's 
>>> structure, I can't see where the download action in the default.py 
>>> controller is ever triggered, since all of that =URL('download', 
>>> args=image.file)}} doesn't *appear* to cause any action with regard to 
>>> the requested image which is being displayed.
>>>
>>> Through experimentation I discovered that I can indeed get a download 
>>> action of the type which I *expected* to be triggered if I manually 
>>> look up the name of the uploaded image file under 
>>> applications/images/uploads/<filename> and then pass it to the download 
>>> action myself in the address bar:
>>>
>>> http://localhost.../images/default/download/<filename>
>>>
>>> That's what I was expecting to happen when I clicked on the image (or 
>>> was somehow otherwise directed to the download action), but apparently I 
>>> was wrong to assume this...?
>>>
>>> In any case, how then does the download action get triggered if not by:
>>>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>>
>>>
>>>
>>> ?
>>>
>>> Any pointers, corrections, directions for further reading, etc. would be 
>>> sincerely appreciated.
>>>
>>>
> On Thursday, July 18, 2013 3:14:41 AM UTC-4, Massimo Di Pierro wrote:
>>
>> I am not sure I fully understand. Are you trying to do this?
>>
>> <a href="{{=URL('download', args=image.file)}}"><img width="200px" 
>> src="{{=URL('download', 
>> args=image.file)}}" /></a>
>>
>>
>>
>> On Thursday, 18 July 2013 01:20:48 UTC-5, REM wrote:
>>>
>>> Hello, folks.
>>>
>>> I started back at the top of the manual again and I am understanding 
>>> much more by progressing slowly and with copious notes. So far, so good. 
>>>
>>> However, I have come across a bit of a puzzling issue with the latter 
>>> part of the "images" tutorial. After creating the dbases, uploading some 
>>> images via appadmin, and then adding the app's core in default.py:
>>>
>>> def index():
>>>     images = db().select(db.image.ALL, orderby=db.image.title)
>>>     return dict(images=images)
>>>
>>>
>>> def show():
>>>     image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
>>>     db.post.image_id.default = image.id
>>>     form = SQLFORM(db.post)
>>>     if form.process().accepted:
>>>         response.flash = 'your comment is posted'
>>>     comments = db(db.post.image_id==image.id).select()
>>>     return dict(image=image, comments=comments, form=form)
>>>
>>>
>>> def download():
>>>     return response.download(request, db)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> And then creating the default/index.html:
>>>
>>> {{extend 'layout.html'}} 
>>> <h1>Current Images</h1> 
>>> <ul> 
>>> {{for image in images:}} 
>>> {{=LI(A(image.title, _href=URL("show", args=image.id)))}} 
>>> {{pass}} 
>>> </ul>
>>>
>>>
>>>
>>>
>>> And finally, the default/show.html:
>>>
>>> {{extend 'layout.html'}}
>>> <h1>Image: {{=image.title}}</h1>
>>> <center>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>> </center>
>>> {{if len(comments):}}
>>>     <h2>Comments</h2><br /><p>
>>>     {{for post in comments:}}
>>>         <p>{{=post.author}} says <i>{{=post.body}}</i></p>
>>>     {{pass}}</p>
>>> {{else:}}
>>> <h2>No comments posted yet</h2>
>>> {{pass}}
>>> <h2>Post a comment</h2>
>>> {{=form}}
>>>
>>>
>>>
>>>
>>>
>>> When the app is called, it behaves as expected in every instance with 
>>> one exception: I was figuring that, based on:
>>>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>>
>>>
>>>
>>> When the image was displayed in the show.html view, that maybe it would 
>>> be tagged with an embedded download link such that passing the mouse over 
>>> the image would indicate a link and then clicking the image would trigger a 
>>> download action to download the image. This does not occur. The app just 
>>> displays the uploaded image with no apparent way to download it (aside from 
>>> the usual right-click browser options). In fact, in looking at the app's 
>>> structure, I can't see where the download action in the default.py 
>>> controller is ever triggered, since all of that =URL('download', 
>>> args=image.file)}} doesn't *appear* to cause any action with regard to 
>>> the requested image which is being displayed.
>>>
>>> Through experimentation I discovered that I can indeed get a download 
>>> action of the type which I *expected* to be triggered if I manually 
>>> look up the name of the uploaded image file under 
>>> applications/images/uploads/<filename> and then pass it to the download 
>>> action myself in the address bar:
>>>
>>> http://localhost.../images/default/download/<filename>
>>>
>>> That's what I was expecting to happen when I clicked on the image (or 
>>> was somehow otherwise directed to the download action), but apparently I 
>>> was wrong to assume this...?
>>>
>>> In any case, how then does the download action get triggered if not by:
>>>
>>> <img width="200px" 
>>>      src="{{=URL('download', args=image.file)}}" />
>>>
>>>
>>>
>>> ?
>>>
>>> Any pointers, corrections, directions for further reading, etc. would be 
>>> sincerely appreciated.
>>>
>>>

-- 

--- 
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/groups/opt_out.


Reply via email to