This works, thank you Massimo

El viernes, 26 de abril de 2013, 18:07:06 (UTC+2), Massimo Di Pierro 
escribió:
>
> Please open a ticket about this. The problem is that the roles of 
> downloading is delegated to the field which stores the upload name. In this 
> case it was uploaded using a SQLFORM.factory ("no_table....") and this is a 
> problem. web2py does not know how to check if the user is allowed to 
> download the file. It does not know who is responsible for the check.
>
> For now you can make your own downloads function:
>
> A(T("Download attachment"), _href=URL("default", "nt_download", args=
> asset_value.upload_value), _target="blank")
>
> def nt_download():
>     if not str(request.args(0)).startwith('no_table.'): raise HTTP(404)
>     return response.stream(
> open(os.path.join(request.folder,'uploads',request.args(0)))
>
> On Tuesday, 23 April 2013 03:25:43 UTC-5, Domagoj Kovač wrote:
>>
>> Hi,
>>
>> I have a download function.
>>
>> def download():
>>     return response.download(request, db)
>>
>> in my controller i have a line of code:
>>
>>     elif field_type == "UPLOAD":
>>         field_value = A(T("Download attachment"), _href=URL("default", 
>> "download", args=asset_value.upload_value), _target="blank")
>>
>> Generated link is:
>> http:
>> //127.0.0.1:8000/init/default/download/no_table.attachment.8c9b795c20c58264.4173736573736d656e7454797065732e786c7378.xlsx
>>
>> When i try to download this file i get 404 error, although file is 
>> uploaded where it should be. 
>>
>> What am i doing wrong, is it because of xlsx extension?
>>
>>

-- 
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/d/optout.

Reply via email to