adam schrieb:
> ok so i have
> 
> @expose(content_type=CUSTOM_CONTENT_TYPE)
>         def Download(self,file):
>             username = request.identity['repoze.who.userid']
>             dir_name = session.get('dir', None)
>             filename = '/home/rubberduckiee/webapps/editor/Xinha/
> plugins/ExtendedFileManager/files'+str(dir_name)+'/'+str(file)
> 
>             st = os.stat(filename)
>             size = st[ST_SIZE]
> 
>             rh = response.headers
>             rh['Pragma'] = 'public' # for IE
>             rh['Expires'] = '0'
>             rh['Cache-control'] = 'must-revalidate, post-check=0, pre-
> check=0' #for IE
>             rh['Cache-control'] = 'max-age=0' #for IE
>             rh['Content-Type'] = 'image/jpg'
>             disposition = 'attachment; filename="'+filename+'"'
>             rh['Content-disposition'] = disposition
>             rh['Content-Transfer-Encoding'] = 'binary'
>             rh['Content-Length'] = size
> 
> 
> a file downloads but the it fails to open because the file is empty.
> What am i missing

Returning the actual file contents? How else should that happen?

And you should get rid of the str() - instead, use the encoding your 
filesystem uses, and do something like


  fname = "/path/%s/%s" % (dir_name.encode("utf-8"), file.encode("utf-8"))


Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to