httmultipartymagic 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/httmultiparty.rb +12 -2
- data/lib/httmultiparty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035ac1fd8af959e1d8f18b7b8eb2fb649483f8e1
|
4
|
+
data.tar.gz: 84628535a459b9c2eee1c1ce5d61a89f4e3e4dbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f041fa44a029578b4738be96e03dd3a2cb7eeeba8f46d473f42534183dafc0c59962b1ff86e4309ee6cfefbc15cd45921c678b3860bfb565860fd8fe58fe9a
|
7
|
+
data.tar.gz: 1e3296177c69d4c5e2adf0313c97ff48b4553e2d9b9a66b5587540f6877d31ecaefbf76b9ce60f26bbb377100e866e4b80be04262e16e0ebcee978972d411c1b
|
data/lib/httmultiparty.rb
CHANGED
@@ -15,8 +15,8 @@ module HTTMultiParty
|
|
15
15
|
else
|
16
16
|
filename = File.split(file.path).last
|
17
17
|
end
|
18
|
-
|
19
|
-
UploadIO.new(file,
|
18
|
+
|
19
|
+
UploadIO.new(file, content_type_of(file, detect_mime_type), filename)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.query_string_normalizer(options = {})
|
@@ -117,6 +117,16 @@ module HTTMultiParty
|
|
117
117
|
upload_io?(value)
|
118
118
|
end
|
119
119
|
|
120
|
+
def self.content_type_of(file, detect_mime_type)
|
121
|
+
if detect_mime_type
|
122
|
+
type = MimeMagic.by_magic file
|
123
|
+
file.rewind
|
124
|
+
type
|
125
|
+
else
|
126
|
+
'application/octet-stream'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
120
130
|
module ClassMethods
|
121
131
|
def post(path, options = {})
|
122
132
|
method = Net::HTTP::Post
|