Improve MIME type determination for trace files.
This commit is contained in:
parent
bce2c88336
commit
16358a1d39
1 changed files with 16 additions and 1 deletions
|
@ -73,7 +73,22 @@ class Trace < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def mime_type
|
def mime_type
|
||||||
return `file -bi #{trace_name}`.chomp
|
filetype = `file -bz #{trace_name}`.chomp
|
||||||
|
gzipped = filetype =~ /gzip compressed/
|
||||||
|
bzipped = filetype =~ /bzip2 compressed/
|
||||||
|
zipped = filetype =~ /Zip archive/
|
||||||
|
|
||||||
|
if gzipped then
|
||||||
|
mimetype = "application/x-gzip"
|
||||||
|
elsif bzipped then
|
||||||
|
mimetype = "application/x-bzip2"
|
||||||
|
elsif zipped
|
||||||
|
mimetype = "application/x-zip"
|
||||||
|
else
|
||||||
|
mimetype = "text/xml"
|
||||||
|
end
|
||||||
|
|
||||||
|
return mimetype
|
||||||
end
|
end
|
||||||
|
|
||||||
def extension_name
|
def extension_name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue