[Zope] External Method file generation Vs MSIE

calisp at gmail.com calisp at gmail.com
Thu Apr 28 05:10:16 EDT 2005


Hi All,

I have an external method that generates files - zip, pdf and xls.  I
would like the browser to present a file open/save dialog box and,
depending on what the user clicks, open or save the file.  Also, I
want to be able to set the file name.  Sounds simple enough and with
most browsers setting the Content-type appropriately and the
Content-Disposition to "attachment; filename="whatever"' works.  I
have not been able to get Internet Explorer to work properly though. 
Has anyone got this working?  If so, how?

Here is a full run down of the problem...

I believe Internet Explorer uses a combination of the following to
decide what to do with a file:

  o  The Content-Type header.
  o  The Content-Disposition header's value.
  o  The Content-Disposition header's filename attribute's extension.
  o  The extension of the external method.
  o  The first part (200 bytes?) of the file contents.
  o  The phase of the moon.  (well, perhaps not, but it's starting to
feel like it.)

It then does one of the following:

  o  Displays the file inline in the browser.
  
  o  Displays the file open/save dialog.  Clicking the save button
saves the file.
      Clicking the open button launches the application that is
associated with the
      file type IE has assumed the file to be but that application
gives a file not found
      error.

  o  Displays the file open/save dialog.  Clicking on open or save
displays another
      file open/save dialog.  Clicking the save button again saves the file.  
      Clicking the open button again launches the application that is
associated with
      the file type IE has assumed the file to be but that application
gives a file not
      found error.

The filename of the file saved or the suggested filename when saving a
file being viewed inline is sometimes the filename attribute in the
content-disposition header and sometimes
"external_method?query=string.ext".

I have tried various combinations of the following:

  o  Setting the Content-Type header to the file type, application/octet-stream,
      application/x-force-download, etc

  o  Not setting the Content-Type header.

  o  Setting the Content-Disposition header to inline, attachment and download
      with and without a filename attribute.

  o  Not setting the Content-Disposition header.

  o  Naming the external method filename.ext where ext is zip, pdf or xls as 
      appropriate.

  o  Hard coding the settings in the external method and not using a
query string.

Despite all this I have completely failed to get MSIE to behave in a
sane manner and would greatly appreciate any advice anyone has on the
matter.

With thanks,


Calisp


More information about the Zope mailing list