mwd-paperclip 2.3.1.1.mwd.b → 2.3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/paperclip/attachment.rb +2 -2
- data/lib/paperclip/upfile.rb +12 -17
- metadata +1 -1
data/lib/paperclip/attachment.rb
CHANGED
|
@@ -90,8 +90,8 @@ module Paperclip
|
|
|
90
90
|
|
|
91
91
|
@queued_for_write[:original] = uploaded_file.to_tempfile
|
|
92
92
|
instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
|
|
93
|
-
overridden_content_type = MIME::Types.type_for(
|
|
94
|
-
instance_write(:content_type, overridden_content_type)
|
|
93
|
+
overridden_content_type = MIME::Types.type_for(original_filename.strip).to_s
|
|
94
|
+
instance_write(:content_type, overridden_content_type)
|
|
95
95
|
instance_write(:file_size, uploaded_file.size.to_i)
|
|
96
96
|
instance_write(:updated_at, Time.now)
|
|
97
97
|
|
data/lib/paperclip/upfile.rb
CHANGED
|
@@ -3,25 +3,20 @@ module Paperclip
|
|
|
3
3
|
# to the +File+ class. Useful for testing.
|
|
4
4
|
# user.avatar = File.new("test/test_avatar.jpg")
|
|
5
5
|
module Upfile
|
|
6
|
-
require 'mime/types'
|
|
7
|
-
|
|
8
|
-
# Infer the MIME-type of the file from the extension.
|
|
9
|
-
# def content_type
|
|
10
|
-
# type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
|
|
11
|
-
# case type
|
|
12
|
-
# when %r"jp(e|g|eg)" then "image/jpeg"
|
|
13
|
-
# when %r"tiff?" then "image/tiff"
|
|
14
|
-
# when %r"png", "gif", "bmp" then "image/#{type}"
|
|
15
|
-
# when "txt" then "text/plain"
|
|
16
|
-
# when %r"html?" then "text/html"
|
|
17
|
-
# when "js" then "application/js"
|
|
18
|
-
# when "csv", "xml", "css" then "text/#{type}"
|
|
19
|
-
# else "application/x-#{type}"
|
|
20
|
-
# end
|
|
21
|
-
# end
|
|
22
6
|
|
|
7
|
+
# Infer the MIME-type of the file from the extension.
|
|
23
8
|
def content_type
|
|
24
|
-
|
|
9
|
+
type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
|
|
10
|
+
case type
|
|
11
|
+
when %r"jp(e|g|eg)" then "image/jpeg"
|
|
12
|
+
when %r"tiff?" then "image/tiff"
|
|
13
|
+
when %r"png", "gif", "bmp" then "image/#{type}"
|
|
14
|
+
when "txt" then "text/plain"
|
|
15
|
+
when %r"html?" then "text/html"
|
|
16
|
+
when "js" then "application/js"
|
|
17
|
+
when "csv", "xml", "css" then "text/#{type}"
|
|
18
|
+
else "application/x-#{type}"
|
|
19
|
+
end
|
|
25
20
|
end
|
|
26
21
|
|
|
27
22
|
# Returns the file's normal name.
|