5

How does Chrome determine the name of the file being saved to disk when downloading a file?

Whenever I download a file from a particular website I am working on (as a developer), Chrome is appending an underscore to the end of the file extension. (See: Chrome on Windows adding trailing underscores to downloaded files? ). I've been playing around with various content-type and content-disposition headers, and it appears that Chrome is ignoring the filename specified in the Content-Disposition header. For example, if I make a request to download a file, and the response comes back with the following headers (among others):

Content-Disposition: attachment;filename="example.pdf"
Content-Type: application/pdf

... the name of the file saved to disk is still the original file name. In this example, the original file is named test.pdf, and rather than saving it as example.pdf (as specified in Content-Disposition), it is being saved to disk as test.pdf. This seems to hold true for any sort of file type - even something as simple as a .txt file. There doesn't appear to be any other HTTP response headers dictating the file name.

Is there something special that Chrome does to determine the name of the file being saved to disk? If so, is it possible to override this behavior?

I understand that Chrome will rename certain downloaded files that it sees as a security risk (e.g.: renaming .lnk to .download), but even in a case like this, it is still ignoring my Content-Disposition headers for safe file types.

Joel B
  • 801
  • 1
  • 11
  • 30

0 Answers0