I'm curious what the methodology is behind the way that gmail (in their web client) offers a "view" and "download" links right next to each other for things like an attached .jpg file. I have found that the browser generally decides how it's going to handle such things based on the file's extension or mime type, but in this case, you have one file and two links and both behaviors offered to the user side by side. I'm assuming it's a server config thing, but I'd like to know what that is, exactly (or if I'm wrong, how they're doing it on the client).
+1
A:
It's almost certainly handled on the server. The "view" link is there for any file that can be viewed in a browser (as in images), as well as any document that can be viewed with Google Apps (MS Office docs, pdfs).
To force a download instead of just viewing in the browser, you need to set the "content-disposition" header to "attachment". See this for an example of how to do this. Google would be doing something like this on the server side.
Matthew Talbert
2009-08-26 07:06:59
right... I'm more curious about how they force the download dialogue to pop up for files that are recognized by the browser as displayable. When you simply link to a jpg it just gets drawn... how do they force it to behave like a non-recognized file type?
Dr.Dredel
2009-08-26 07:43:17
+1
A:
It's likely just setting a Content-disposition header at the server level for the "download" link (forcing a save as/open dialog), and allowing the browser to handle it normally for the view link.