Skip to content

Commit

Permalink
Explicitly register supported mime types (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalexling committed Jul 1, 2020
1 parent fe082e7 commit f5cdf8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/library.cr
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ class Library

def initialize
@storage = Storage.default
register_mime_types

@dir = Config.current.library_path
@scan_interval = Config.current.scan_interval
# explicitly initialize @titles to bypass the compiler check. it will
Expand Down
13 changes: 11 additions & 2 deletions src/util.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def send_json(env, json)
end

def send_attachment(env, path)
MIME.register ".cbz", "application/vnd.comicbook+zip"
MIME.register ".cbr", "application/vnd.comicbook-rar"
send_file env, path, filename: File.basename(path), disposition: "attachment"
end

Expand Down Expand Up @@ -164,3 +162,14 @@ def escape_xml(str)
'&' => "&",
})
end

def register_mime_types
{
".zip" => "application/zip",
".rar" => "application/x-rar-compressed",
".cbz" => "application/vnd.comicbook+zip",
".cbr" => "application/vnd.comicbook-rar",
}.each do |k, v|
MIME.register k, v
end
end

0 comments on commit f5cdf8b

Please sign in to comment.