On Tue, Feb 22, 2011 at 1:41 PM, Diez B. Roggisch <[email protected]> wrote: > > This should get you started: > > from tg import expose, response > from tg.controllers import CUSTOM_CONTENT_TYPE > > @expose(content_type=CUSTOM_CONTENT_TYPE) > def download__file(self): > rh = response.headers > rh['Content-Type'] = 'application/octet-stream; charset=utf-8' > #response.content_type = 'application/octet-stream' > disposition = 'attachment; filename="filename.ext"' > rh['Content-disposition'] = disposition > rh['Pragma'] = 'public' # for IE > rh['Cache-control'] = 'max-age=0' #for IE > return "these are the file contents" >
Also I would suggest: disposition = 'inline; filename="filename.ext"' instead of attachment as some browsers will propose you a Save As dialog box instead of showing the content if content disposition is attachment. Also you should think about enabling etag_cache as it will improve a lot performances in those cases. -- 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.

