rails-uploader 0.2.4 → 0.2.5
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/app/controllers/uploader/attachments_controller.rb +1 -3
- data/lib/uploader.rb +13 -0
- data/lib/uploader/version.rb +1 -1
- metadata +2 -2
@@ -47,10 +47,8 @@ module Uploader
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def render_json(hash_or_object, status = 200)
|
50
|
-
ctype = env["HTTP_USER_AGENT"] && env["HTTP_USER_AGENT"].include?("Android") ? "text/plain" : "application/json"
|
51
|
-
|
52
50
|
self.status = status
|
53
|
-
self.content_type =
|
51
|
+
self.content_type = Uploader.content_type(env["HTTP_USER_AGENT"])
|
54
52
|
self.response_body = hash_or_object.to_json(:root => false)
|
55
53
|
end
|
56
54
|
end
|
data/lib/uploader.rb
CHANGED
@@ -31,6 +31,19 @@ module Uploader
|
|
31
31
|
return if klass.blank?
|
32
32
|
klass.safe_constantize
|
33
33
|
end
|
34
|
+
|
35
|
+
def self.content_type(user_agent)
|
36
|
+
return "application/json" if user_agent.blank?
|
37
|
+
|
38
|
+
ie_version = user_agent.scan(/(MSIE\s|rv:)([\d\.]+)/).flatten.last
|
39
|
+
|
40
|
+
if user_agent.include?("Android") || (ie_version && ie_version.to_f <= 9.0) || (user_agent =~ /Trident\/[0-9\.]+\;/i)
|
41
|
+
"text/plain"
|
42
|
+
else
|
43
|
+
"application/json"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
end
|
35
48
|
|
36
49
|
require 'uploader/engine'
|
data/lib/uploader/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jquery-ui-rails
|