mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add Blob#disposition
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
require 'linguist/mime'
|
||||
require 'linguist/pathname'
|
||||
|
||||
require 'escape_utils'
|
||||
|
||||
module Linguist
|
||||
class Blob
|
||||
def initialize(blob)
|
||||
@@ -18,6 +20,15 @@ module Linguist
|
||||
Mime.lookup(name.extname)
|
||||
end
|
||||
|
||||
def disposition
|
||||
case mime_type
|
||||
when 'application/octet-stream', 'application/java-archive'
|
||||
"attachment; filename=#{EscapeUtils.escape_url(name.to_s)}"
|
||||
else
|
||||
'inline'
|
||||
end
|
||||
end
|
||||
|
||||
def size
|
||||
@blob.size
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user