mt.encode('utf-8') might end up being wrong, HTTP Headers should only
be latin1 if I remember correctly.
Even though, probably, there aren't mime types which contain utf8 characters.Also you should be able to use response.content_type = 'yourcontenttype' and response.headers['Content-Disposition']=... instead of relying on response.headerlist.append, which is a bit easier to read and write. On Thu, Oct 11, 2012 at 1:51 PM, León Domingo <[email protected]> wrote: > Hi people, > > I have this controller method: > > @expose() > def get(self, codigo): > > aa = dbs.query(ArchivosAsociados).\ > filter(ArchivosAsociados.codigo == codigo).first() > > if aa.caducidad and aa.caducidad > dt.datetime.now(): > content, mt, file_name = SapnsDoc.download(aa.id_recurso) > response.headerlist.append(('Content-Type', mt.encode('utf-8'))) > response.headerlist.append(('Content-Disposition', > 'attachment;filename=%s' % file_name)) > > return content > > else: > redirect(url('/banco_de_recursos/recurso_caducado/', > params=dict(codigo=codigo))) > > As you can see "mime-type" is "calculated" ("Content-Type" header is added > dynamically) inside the method. I've read a record from the database which > gives me the "mime-type" (mt) and "file name" (file_name). Content (content) > is read from the file itself which is stored in the hard disk. > > Ok, this thing does not work on IE8 or IE7. Chrome, FF, Opera, Safari or > even IE9 do the right thing. > > Any suggestion? > > Thanks in advance > > León > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/turbogears/-/EIFdY1yODPgJ. > 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. -- 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.

