On 5/10/13 5:27 AM, Rönkkö Mikko wrote:
> {"itemType":"attachment","linkMode":"imported_url","title":"SEP - Snapshot","accessDate":"2012-02-13 22:23:51","url":"
http://plato.stanford.edu/archives/sum2011/entriesuring/","note":"","contentType":"","charset":"","filename":"Hodges - 2011 - Alan Turing","md5":"8a98656a97063077e89c9d622f8e8810","mtime":1329171831000,"tags":[]}
>
> This item does not have a file name extension or content type and the URL does not reveal the content type either. Is this expected behavior, or a bug? How does Zotero know which application it uses to open this file when a user clicks on it?
That generally shouldn't happen, but it can in some situations.
As for how Zotero deals with it, first, Zotero actually doesn't know
what applications opens files—all it cares about is whether files can be
handled natively within Firefox/Standalone or whether they need to be
opened by the system. But that does mean having at least a rough idea of
the content type, so it uses a combination of data from the beginning of
the file and the file extension to figure out the content type. For the
former, it uses a handful of magic patterns from the 'file' command
database. If it can't figure it out based on the data sample or the
extension, it will just determine if the file is text or binary, and
open the file externally if the latter. See viewAttachment() in
zoteroPane.js and the various functions in mime.js for some of the
details here.
At the moment we don't update the contentType in the DB if we figure it
out later (e.g., if we've gotten smarter, or the file has been renamed),
but we might do that at some point.