lib/ncmb/client.rb in ncmb-ruby-client-0.1.2 vs lib/ncmb/client.rb in ncmb-ruby-client-0.1.3
- old
+ new
@@ -155,11 +155,16 @@
when :get
query = encode_query(queries).map do |key, value|
"#{key}=#{value}"
end.join("&")
path = path + (query == '' ? "" : "?"+query)
- json = JSON.parse(http.get(path, headers).body, symbolize_names: true)
+ rp = Regexp.new "/#{NCMB::API_VERSION}/files/.*"
+ if path =~ rp
+ json = http.get(path, headers).body
+ else
+ json = JSON.parse(http.get(path, headers).body, symbolize_names: true)
+ end
when :post
req = Net::HTTP::Post.new(path)
if queries[:file].is_a?(File) || queries[:file].is_a?(StringIO)
boundary = SecureRandom.uuid
req.body = make_boundary(boundary, queries)
@@ -193,10 +198,10 @@
end
rescue => e
@@last_error = e
raise NCMB::APIError.new(e.to_s)
end
- if json[:error] != nil
+ if json.is_a?(Hash) && json[:error] != nil
raise NCMB::APIError.new(json[:error])
end
json
end
end