I have implemented a basic file upload/download on top of AppEngine datastore.
The functionality that I want is that a file named “base.c” will be opened as a text file.
so I did the following:
(of course my code is for a general case but this specific example illustrates the problem)
resp.setContentType("text/plain");
resp.setHeader("Content-Disposition", "inline; filename=base.c");
This opens it as a text file in the browser which is just what I needed.
But I also want that when the user uses the browser’s “save page as..” option it will offer the initial name of “base.c”. It does just that in firefox(6) but it gives the default name of “download” on chrome(15) and safari(5).
Even worse – when choosing base.c as the file name chrome warns the user that this is the wrong extension and asks for confirmation to continue.
Now if I use “attachment” instead of “inline” it does not open the file but download it with the right name.
What can I do to make the default save as.. name be “base.c”?
Is this the browser’s fault or am I misusing the HTTP headers?
(if it is any help, all test were on OSX 10.6 and the download site is of the sort:
http://——.appspot.com/download?name=base.c)
This is a known issue; see http://greenbytes.de/tech/tc2231/#inlwithasciifilename — only FF gets this right.