ruby-cleverdome 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby-cleverdome.rb +21 -3
- data/lib/ruby-cleverdome/multipart.rb +3 -1
- metadata +1 -1
data/lib/ruby-cleverdome.rb
CHANGED
@@ -14,12 +14,12 @@ module RubyCleverdome
|
|
14
14
|
@sso_client = Savon.client(
|
15
15
|
endpoint: sso_endpoint,
|
16
16
|
namespace: 'urn:up-us:sso-service:service:v1',
|
17
|
-
#
|
17
|
+
#proxy: 'http://127.0.0.1:8888',
|
18
18
|
# log_level: :debug
|
19
19
|
)
|
20
20
|
@widgets_client = Savon.client(
|
21
21
|
wsdl: widgets_path + '?wsdl',
|
22
|
-
#
|
22
|
+
#proxy: 'http://127.0.0.1:8888',
|
23
23
|
element_form_default: :unqualified,
|
24
24
|
# log_level: :debug
|
25
25
|
)
|
@@ -50,7 +50,25 @@ module RubyCleverdome
|
|
50
50
|
def upload_file(session_id, app_id, file_path)
|
51
51
|
data, headers = Multipart::Post.prepare_query(
|
52
52
|
"sessionID" => session_id,
|
53
|
-
"file" => File.open(file_path),
|
53
|
+
"file" => File.open(file_path, 'rb'),
|
54
|
+
'applicationID' => app_id
|
55
|
+
)
|
56
|
+
|
57
|
+
response = @widgets_client.call(
|
58
|
+
:upload_file,
|
59
|
+
:attributes => {
|
60
|
+
'xmlns' => 'http://tempuri.org/'
|
61
|
+
},
|
62
|
+
message: {
|
63
|
+
inputStream: Base64.encode64(data)
|
64
|
+
})
|
65
|
+
response.body[:upload_file_response][:upload_file_result]
|
66
|
+
end
|
67
|
+
|
68
|
+
def upload_file_binary(session_id, app_id, filename, binary_data)
|
69
|
+
data, headers = Multipart::Post.prepare_query(
|
70
|
+
"sessionID" => session_id,
|
71
|
+
"file" => { 'filename' => filename, 'data' => binary_data },
|
54
72
|
'applicationID' => app_id
|
55
73
|
)
|
56
74
|
|
@@ -31,6 +31,8 @@ module Multipart
|
|
31
31
|
# Are we trying to make a file parameter?
|
32
32
|
if v.respond_to?(:path) and v.respond_to?(:read) then
|
33
33
|
fp.push(FileParam.new(k, v.path, v.read))
|
34
|
+
elsif v.is_a?(Hash) and v.has_key?('filename') and v.has_key?('data') then
|
35
|
+
fp.push(FileParam.new(k, v['filename'], v['data']))
|
34
36
|
# We must be trying to make a regular parameter
|
35
37
|
else
|
36
38
|
fp.push(StringParam.new(k, v))
|
@@ -38,7 +40,7 @@ module Multipart
|
|
38
40
|
end
|
39
41
|
|
40
42
|
# Assemble the request body using the special multipart format
|
41
|
-
query = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--"
|
43
|
+
query = (fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--")
|
42
44
|
return query, HEADER
|
43
45
|
end
|
44
46
|
end
|