I have a collection of files that I am storing in S3, and for various reasons, the actual name of the S3 object is not the original filename. But I am using the Content-Disposition header to set the filename I want the browser to use. And it works correctly for certain files in certain browsers. But for some reason, for inline text files in Chrome it doesn't.
Here's an example: https://dev-download.veoci.com/mapicons/4.txt
The object name (or I guess technically the last part of the path of the object name) is 4.txt but I set the Content-Disposition filename to be hello.txt
So why does Chrome save it as 4.txt and how do I fix it?
Note - this is specific to the situation where we view the file inline and then press Save. If the Content-Disposition is attachment to start out with, the correct filename is used.
In the case of inline text files in Chrome, the browser may use the object's actual filename instead of the suggested filename in the
Content-Dispositionheader. You may try to work around this by setting your file'sContent-Typeheader to a MIME type that Chrome recognizes as a downloadable file, such asapplication/octet-stream. This may trick Chrome into treating the file as downloadable instead of displaying it inline, using the suggested filename in theContent-Dispositionheader.