       init: (url, data, sendResponseCallback) ->
         item = Zotero.Items.getByLibraryAndKey(url.query.library, url.query.key)
         body = Zotero.File.getBinaryContents(item.getFile())
-        sendResponseCallback(200, item.attachmentMIMEType || 'application/pdf', body)
+        sendResponseCallback(200, Zotero.OPDS.contentType(item) || 'application/pdf', body)
 
     group:
       supportedMethods: ["GET"]

      @add(summary: {type: 'text', '': abstr}) if abstr && abstr.length != 0

      for attachment in attachments
        Zotero.OPDS.log("attachment #{attachment.getFilename()} has type #{attachment.attachmentMIMEType} / #{Zotero.OPDS.MIMEService.getTypeFromExtension(attachment.getFilename().replace(/.*\./, ''))}")

        @add(link: {
          type: attachment.attachmentMIMEType || 'application/pdf'
          rel: 'http://opds-spec.org/acquisition'
          href: "/opds/item?library=#{attachment.libraryID || 0}&key=#{attachment.key}"
          })


    Zotero.debug("[opds] #{msg.join(' ')}")
    return

  contentType: (attachment) ->
    return attachment.attachmentMIMEType if attachment.attachmentMIMEType && attachment.attachmentMIMEType != 'application/octet-stream'
    ext = attachment.getFilename().replace(/.*\./, '').toLowerCase()
    return switch ext
      when 'epub' then 'application/epub+zip'
      when 'pdf' then 'application/pdf'
      else null

  url: ->
    try
