Hello,

I've got a table with files inserted into an upload field. Downloading 
works fine when I pass the file path to the default download controller. 

<td>{{=A('Download', _href=URL('default', 'download', 
args=download_path))}}</td>  

However, I'd like the user to be able to change only the name of the file 
that is downloaded without having to do any file copying or additional 
database inserts. Nor do I want to break web2py's file renaming system. I 
want to allow for the possibility that the user might decide to rename the 
file later on after they uploaded it by storing the new name and presenting 
it at download time.. it seems like this can be done via response.stream 
but I cannot make this happen..

I've tried these two strategies (and many modifications) but get errors, 
404 not found, or invalid requests...

in the view-

    <td>{{=A('Download1', _href=URL('default', 'download1', 
args=[download_path, 'new_title']))}}</td>   
    <td>{{=A('Download2', _href=URL('default', 'download2', 
args=[download_path, 'new_title']))}}</td>   


in the default controller-

@auth.requires_login()
def download1():
    response.headers['Content-Type'] = "application/octet-stream"
    response.headers['Content-Disposition'] = 'attachment; filename=%s' % 
request.args(1)

    return response.stream(request.args(0))


@auth.requires_login()
def download2():

    return response.stream(request.args(0), attachment=True, 
filename=request.args(1))



...is this possible? Thanks in advance for help.
-j

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to