groupdocs 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +2 -0
- data/examples/api-samples/public/docs/annotation-sample.html +167 -57
- data/examples/api-samples/public/docs/docco.css +459 -151
- data/examples/api-samples/public/docs/envelope-sample.html +373 -131
- data/examples/api-samples/public/docs/sample1.html +126 -26
- data/examples/api-samples/public/docs/sample10.html +213 -50
- data/examples/api-samples/public/docs/sample11.html +319 -87
- data/examples/api-samples/public/docs/sample12.html +165 -40
- data/examples/api-samples/public/docs/sample13.html +166 -41
- data/examples/api-samples/public/docs/sample14.html +142 -30
- data/examples/api-samples/public/docs/sample15.html +127 -27
- data/examples/api-samples/public/docs/sample16.html +125 -25
- data/examples/api-samples/public/docs/sample17.html +188 -37
- data/examples/api-samples/public/docs/sample18.html +614 -157
- data/examples/api-samples/public/docs/sample19.html +221 -59
- data/examples/api-samples/public/docs/sample2.html +142 -30
- data/examples/api-samples/public/docs/sample20.html +176 -51
- data/examples/api-samples/public/docs/sample21.html +287 -66
- data/examples/api-samples/public/docs/sample22.html +224 -53
- data/examples/api-samples/public/docs/sample23.html +256 -0
- data/examples/api-samples/public/docs/sample24.html +143 -0
- data/examples/api-samples/public/docs/sample25.html +429 -0
- data/examples/api-samples/public/docs/sample26.html +113 -0
- data/examples/api-samples/public/docs/sample27.html +433 -0
- data/examples/api-samples/public/docs/sample28.html +185 -0
- data/examples/api-samples/public/docs/sample29.html +175 -0
- data/examples/api-samples/public/docs/sample3.html +172 -34
- data/examples/api-samples/public/docs/sample30.html +144 -0
- data/examples/api-samples/public/docs/sample31.html +734 -0
- data/examples/api-samples/public/docs/sample4.html +204 -52
- data/examples/api-samples/public/docs/sample5.html +241 -63
- data/examples/api-samples/public/docs/sample6.html +209 -48
- data/examples/api-samples/public/docs/sample7.html +155 -43
- data/examples/api-samples/public/docs/sample8.html +235 -62
- data/examples/api-samples/public/docs/sample9.html +200 -49
- data/examples/api-samples/public/templates/merge_field1_doc.docx +0 -0
- data/examples/api-samples/public/templates/merge_field2_doc.docx +0 -0
- data/examples/api-samples/samples/sample23.rb +54 -0
- data/examples/api-samples/samples/sample24.rb +30 -0
- data/examples/api-samples/samples/sample25.rb +4 -4
- data/examples/api-samples/samples/sample26.rb +25 -0
- data/examples/api-samples/samples/sample27.rb +100 -0
- data/examples/api-samples/samples/sample28.rb +47 -0
- data/examples/api-samples/samples/sample29.rb +52 -0
- data/examples/api-samples/samples/sample30.rb +39 -0
- data/examples/api-samples/samples/sample31.rb +204 -0
- data/examples/api-samples/samples/sample5.rb +5 -3
- data/examples/api-samples/samples/sample6.rb +2 -0
- data/examples/api-samples/views/_others_samples.haml +12 -0
- data/examples/api-samples/views/index.haml +12 -0
- data/examples/api-samples/views/layout.haml +1 -0
- data/examples/api-samples/views/sample1.haml +3 -2
- data/examples/api-samples/views/sample10.haml +3 -2
- data/examples/api-samples/views/sample11.haml +4 -0
- data/examples/api-samples/views/sample12.haml +4 -0
- data/examples/api-samples/views/sample13.haml +4 -0
- data/examples/api-samples/views/sample14.haml +4 -0
- data/examples/api-samples/views/sample15.haml +4 -0
- data/examples/api-samples/views/sample16.haml +4 -0
- data/examples/api-samples/views/sample17.haml +4 -0
- data/examples/api-samples/views/sample19.haml +4 -0
- data/examples/api-samples/views/sample2.haml +3 -2
- data/examples/api-samples/views/sample20.haml +4 -0
- data/examples/api-samples/views/sample21.haml +4 -0
- data/examples/api-samples/views/sample22.haml +4 -0
- data/examples/api-samples/views/sample23.haml +87 -0
- data/examples/api-samples/views/sample24.haml +44 -0
- data/examples/api-samples/views/sample26.haml +54 -0
- data/examples/api-samples/views/sample27.haml +122 -0
- data/examples/api-samples/views/sample28.haml +47 -0
- data/examples/api-samples/views/sample29.haml +70 -0
- data/examples/api-samples/views/sample3.haml +3 -2
- data/examples/api-samples/views/sample30.haml +46 -0
- data/examples/api-samples/views/sample31.haml +114 -0
- data/examples/api-samples/views/sample4.haml +3 -2
- data/examples/api-samples/views/sample5.haml +3 -2
- data/examples/api-samples/views/sample6.haml +3 -2
- data/examples/api-samples/views/sample7.haml +3 -2
- data/examples/api-samples/views/sample8.haml +3 -2
- data/examples/api-samples/views/sample9.haml +3 -2
- data/examples/viewer/Gemfile +1 -1
- data/groupdocs.gemspec +3 -3
- data/lib/groupdocs/datasource.rb +22 -0
- data/lib/groupdocs/document.rb +493 -43
- data/lib/groupdocs/document/annotation.rb +73 -0
- data/lib/groupdocs/job.rb +82 -1
- data/lib/groupdocs/post.rb +83 -0
- data/lib/groupdocs/questionnaire.rb +41 -0
- data/lib/groupdocs/signature.rb +342 -0
- data/lib/groupdocs/signature/envelope.rb +56 -0
- data/lib/groupdocs/signature/form.rb +47 -5
- data/lib/groupdocs/signature/shared/field_methods.rb +37 -0
- data/lib/groupdocs/storage/file.rb +83 -0
- data/lib/groupdocs/subscription.rb +218 -0
- data/lib/groupdocs/user.rb +422 -1
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/job_spec.rb +4 -5
- data/spec/groupdocs/user_spec.rb +157 -0
- data/spec/support/json/annotation_resize.json +11 -0
- data/spec/support/json/annotation_text_color.json +10 -0
- data/spec/support/json/annotation_text_info.json +11 -0
- data/spec/support/json/document_content_get.json +8 -0
- data/spec/support/json/document_edit_lock_get.json +10 -0
- data/spec/support/json/document_editlock_remove.json +8 -0
- data/spec/support/json/document_page_html_urls_get.json +14 -0
- data/spec/support/json/document_password_set.json +19 -0
- data/spec/support/json/document_representations.json +25 -0
- data/spec/support/json/document_shared_documents_get.json +32 -0
- data/spec/support/json/document_tags_get.json +9 -0
- data/spec/support/json/document_tags_remove.json +8 -0
- data/spec/support/json/document_tags_set.json +8 -0
- data/spec/support/json/document_user_status_set.json +12 -0
- data/spec/support/json/job_documents.json +103 -35
- data/spec/support/json/job_xml_get.json +30 -0
- data/spec/support/json/jobs_documents.json +40 -0
- data/spec/support/json/user_get_profile.json +73 -0
- metadata +49 -177
@@ -1,52 +1,204 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>sample4.rb</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
7
|
+
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
8
|
+
<link rel="stylesheet" media="all" href="docco.css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<div id="background"></div>
|
13
|
+
|
14
|
+
<ul class="sections">
|
15
|
+
|
16
|
+
<li id="title">
|
17
|
+
<div class="annotation">
|
18
|
+
<h1>sample4.rb</h1>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
<li id="section-1">
|
25
|
+
<div class="annotation">
|
26
|
+
|
27
|
+
<div class="pilwrap ">
|
28
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
29
|
+
</div>
|
30
|
+
<p>GET request</p>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="content"><div class='highlight'><pre>get <span class="string">'/sample4'</span> <span class="keyword">do</span>
|
35
|
+
haml <span class="symbol">:sample4</span>
|
36
|
+
<span class="keyword">end</span></pre></div></div>
|
37
|
+
|
38
|
+
</li>
|
39
|
+
|
40
|
+
|
41
|
+
<li id="section-2">
|
42
|
+
<div class="annotation">
|
43
|
+
|
44
|
+
<div class="pilwrap ">
|
45
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
46
|
+
</div>
|
47
|
+
<p>POST request</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="content"><div class='highlight'><pre>post <span class="string">'/sample4'</span> <span class="keyword">do</span></pre></div></div>
|
52
|
+
|
53
|
+
</li>
|
54
|
+
|
55
|
+
|
56
|
+
<li id="section-3">
|
57
|
+
<div class="annotation">
|
58
|
+
|
59
|
+
<div class="pilwrap ">
|
60
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
61
|
+
</div>
|
62
|
+
<p>set variables</p>
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:client_id</span>]
|
67
|
+
set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</span>]
|
68
|
+
set <span class="symbol">:file_id</span>, params[<span class="symbol">:file_id</span>]
|
69
|
+
set <span class="symbol">:source</span>, params[<span class="symbol">:source</span>]
|
70
|
+
set <span class="symbol">:url</span>, params[<span class="symbol">:url</span>]
|
71
|
+
|
72
|
+
<span class="keyword">begin</span></pre></div></div>
|
73
|
+
|
74
|
+
</li>
|
75
|
+
|
76
|
+
|
77
|
+
<li id="section-4">
|
78
|
+
<div class="annotation">
|
79
|
+
|
80
|
+
<div class="pilwrap ">
|
81
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
82
|
+
</div>
|
83
|
+
<p>check required variables</p>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty?</pre></div></div>
|
88
|
+
|
89
|
+
</li>
|
90
|
+
|
91
|
+
|
92
|
+
<li id="section-5">
|
93
|
+
<div class="annotation">
|
94
|
+
|
95
|
+
<div class="pilwrap ">
|
96
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
97
|
+
</div>
|
98
|
+
<p>get file GUID</p>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div class="content"><div class='highlight'><pre> file = <span class="keyword">nil</span>
|
103
|
+
<span class="keyword">case</span> settings.source
|
104
|
+
<span class="keyword">when</span> <span class="string">'guid'</span>
|
105
|
+
file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> => settings.file_id})
|
106
|
+
<span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
|
107
|
+
|
108
|
+
</li>
|
109
|
+
|
110
|
+
|
111
|
+
<li id="section-6">
|
112
|
+
<div class="annotation">
|
113
|
+
|
114
|
+
<div class="pilwrap ">
|
115
|
+
<a class="pilcrow" href="#section-6">¶</a>
|
116
|
+
</div>
|
117
|
+
<p>construct path</p>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div class="content"><div class='highlight'><pre> filepath = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:file</span>][<span class="symbol">:filename</span>]}</span>"</span></pre></div></div>
|
122
|
+
|
123
|
+
</li>
|
124
|
+
|
125
|
+
|
126
|
+
<li id="section-7">
|
127
|
+
<div class="annotation">
|
128
|
+
|
129
|
+
<div class="pilwrap ">
|
130
|
+
<a class="pilcrow" href="#section-7">¶</a>
|
131
|
+
</div>
|
132
|
+
<p>open file</p>
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(filepath, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
|
137
|
+
|
138
|
+
</li>
|
139
|
+
|
140
|
+
|
141
|
+
<li id="section-8">
|
142
|
+
<div class="annotation">
|
143
|
+
|
144
|
+
<div class="pilwrap ">
|
145
|
+
<a class="pilcrow" href="#section-8">¶</a>
|
146
|
+
</div>
|
147
|
+
<p>make a request to API using client_id and private_key</p>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(filepath, {}, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
|
152
|
+
<span class="keyword">when</span> <span class="string">'url'</span>
|
153
|
+
file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
|
154
|
+
<span class="keyword">else</span>
|
155
|
+
raise <span class="string">'Wrong GUID source.'</span>
|
156
|
+
<span class="keyword">end</span>
|
157
|
+
|
158
|
+
pp file
|
159
|
+
pp file.name</pre></div></div>
|
160
|
+
|
161
|
+
</li>
|
162
|
+
|
163
|
+
|
164
|
+
<li id="section-9">
|
165
|
+
<div class="annotation">
|
166
|
+
|
167
|
+
<div class="pilwrap ">
|
168
|
+
<a class="pilcrow" href="#section-9">¶</a>
|
169
|
+
</div>
|
170
|
+
<p>download file</p>
|
171
|
+
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div class="content"><div class='highlight'><pre> dowloaded_file = file.download!(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span>, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
175
|
+
<span class="keyword">unless</span> dowloaded_file.empty?
|
176
|
+
massage = <span class="string">"<font color='green'>File was downloaded to the <font color='blue'><span class="subst">#{dowloaded_file}</span></font> folder</font> <br />"</span>
|
177
|
+
<span class="keyword">end</span>
|
178
|
+
|
179
|
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
|
180
|
+
err = e.message
|
181
|
+
<span class="keyword">end</span></pre></div></div>
|
182
|
+
|
183
|
+
</li>
|
184
|
+
|
185
|
+
|
186
|
+
<li id="section-10">
|
187
|
+
<div class="annotation">
|
188
|
+
|
189
|
+
<div class="pilwrap ">
|
190
|
+
<a class="pilcrow" href="#section-10">¶</a>
|
191
|
+
</div>
|
192
|
+
<p>set variables for template</p>
|
193
|
+
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample4</span>, <span class="symbol">:locals</span> => {<span class="symbol">:userId</span> => settings.client_id, <span class="symbol">:privateKey</span> => settings.private_key, <span class="symbol">:file_id</span> => settings.file_id, <span class="symbol">:massage</span> => massage, <span class="symbol">:err</span> => err}
|
197
|
+
<span class="keyword">end</span></pre></div></div>
|
198
|
+
|
199
|
+
</li>
|
200
|
+
|
201
|
+
</ul>
|
202
|
+
</div>
|
203
|
+
</body>
|
204
|
+
</html>
|
@@ -1,63 +1,241 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>sample5.rb</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
7
|
+
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
8
|
+
<link rel="stylesheet" media="all" href="docco.css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="container">
|
12
|
+
<div id="background"></div>
|
13
|
+
|
14
|
+
<ul class="sections">
|
15
|
+
|
16
|
+
<li id="title">
|
17
|
+
<div class="annotation">
|
18
|
+
<h1>sample5.rb</h1>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
<li id="section-1">
|
25
|
+
<div class="annotation">
|
26
|
+
|
27
|
+
<div class="pilwrap ">
|
28
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
29
|
+
</div>
|
30
|
+
<p>GET request</p>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="content"><div class='highlight'><pre>get <span class="string">'/sample5'</span> <span class="keyword">do</span>
|
35
|
+
haml <span class="symbol">:sample5</span>
|
36
|
+
<span class="keyword">end</span></pre></div></div>
|
37
|
+
|
38
|
+
</li>
|
39
|
+
|
40
|
+
|
41
|
+
<li id="section-2">
|
42
|
+
<div class="annotation">
|
43
|
+
|
44
|
+
<div class="pilwrap ">
|
45
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
46
|
+
</div>
|
47
|
+
<p>POST request</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="content"><div class='highlight'><pre>post <span class="string">'/sample5'</span> <span class="keyword">do</span></pre></div></div>
|
52
|
+
|
53
|
+
</li>
|
54
|
+
|
55
|
+
|
56
|
+
<li id="section-3">
|
57
|
+
<div class="annotation">
|
58
|
+
|
59
|
+
<div class="pilwrap ">
|
60
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
61
|
+
</div>
|
62
|
+
<p>set variables</p>
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:client_id</span>]
|
67
|
+
set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</span>]
|
68
|
+
set <span class="symbol">:file_id</span>, params[<span class="symbol">:fileId</span>]
|
69
|
+
set <span class="symbol">:url</span>, params[<span class="symbol">:url</span>]
|
70
|
+
set <span class="symbol">:copy</span>, params[<span class="symbol">:copy</span>]
|
71
|
+
set <span class="symbol">:move</span>, params[<span class="symbol">:move</span>]
|
72
|
+
set <span class="symbol">:dest_path</span>, params[<span class="symbol">:dest_path</span>]
|
73
|
+
set <span class="symbol">:source</span>, params[<span class="symbol">:source</span>]
|
74
|
+
|
75
|
+
<span class="keyword">begin</span></pre></div></div>
|
76
|
+
|
77
|
+
</li>
|
78
|
+
|
79
|
+
|
80
|
+
<li id="section-4">
|
81
|
+
<div class="annotation">
|
82
|
+
|
83
|
+
<div class="pilwrap ">
|
84
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
85
|
+
</div>
|
86
|
+
<p>check required variables</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
<div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty?
|
91
|
+
|
92
|
+
file = <span class="keyword">nil</span></pre></div></div>
|
93
|
+
|
94
|
+
</li>
|
95
|
+
|
96
|
+
|
97
|
+
<li id="section-5">
|
98
|
+
<div class="annotation">
|
99
|
+
|
100
|
+
<div class="pilwrap ">
|
101
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
102
|
+
</div>
|
103
|
+
<p>get document by file GUID</p>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.source
|
108
|
+
<span class="keyword">when</span> <span class="string">'guid'</span>
|
109
|
+
file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> => settings.file_id})
|
110
|
+
<span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
|
111
|
+
|
112
|
+
</li>
|
113
|
+
|
114
|
+
|
115
|
+
<li id="section-6">
|
116
|
+
<div class="annotation">
|
117
|
+
|
118
|
+
<div class="pilwrap ">
|
119
|
+
<a class="pilcrow" href="#section-6">¶</a>
|
120
|
+
</div>
|
121
|
+
<p>construct path</p>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<div class="content"><div class='highlight'><pre> filepath = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:file</span>][<span class="symbol">:filename</span>]}</span>"</span></pre></div></div>
|
126
|
+
|
127
|
+
</li>
|
128
|
+
|
129
|
+
|
130
|
+
<li id="section-7">
|
131
|
+
<div class="annotation">
|
132
|
+
|
133
|
+
<div class="pilwrap ">
|
134
|
+
<a class="pilcrow" href="#section-7">¶</a>
|
135
|
+
</div>
|
136
|
+
<p>open file</p>
|
137
|
+
|
138
|
+
</div>
|
139
|
+
|
140
|
+
<div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(filepath, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
|
141
|
+
|
142
|
+
</li>
|
143
|
+
|
144
|
+
|
145
|
+
<li id="section-8">
|
146
|
+
<div class="annotation">
|
147
|
+
|
148
|
+
<div class="pilwrap ">
|
149
|
+
<a class="pilcrow" href="#section-8">¶</a>
|
150
|
+
</div>
|
151
|
+
<p>make a request to API using client_id and private_key</p>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
<div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(filepath, {}, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
|
156
|
+
<span class="keyword">when</span> <span class="string">'url'</span>
|
157
|
+
file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
|
158
|
+
<span class="keyword">else</span>
|
159
|
+
raise <span class="string">'Wrong GUID source.'</span>
|
160
|
+
<span class="keyword">end</span></pre></div></div>
|
161
|
+
|
162
|
+
</li>
|
163
|
+
|
164
|
+
|
165
|
+
<li id="section-9">
|
166
|
+
<div class="annotation">
|
167
|
+
|
168
|
+
<div class="pilwrap ">
|
169
|
+
<a class="pilcrow" href="#section-9">¶</a>
|
170
|
+
</div>
|
171
|
+
<p>raise files_list.to_yaml
|
172
|
+
copy file using request to API</p>
|
173
|
+
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> settings.copy.<span class="keyword">nil</span>?
|
177
|
+
file = file.copy!(settings.dest_path, {}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
178
|
+
button = settings.copy
|
179
|
+
<span class="keyword">end</span></pre></div></div>
|
180
|
+
|
181
|
+
</li>
|
182
|
+
|
183
|
+
|
184
|
+
<li id="section-10">
|
185
|
+
<div class="annotation">
|
186
|
+
|
187
|
+
<div class="pilwrap ">
|
188
|
+
<a class="pilcrow" href="#section-10">¶</a>
|
189
|
+
</div>
|
190
|
+
<p>move file using request to API</p>
|
191
|
+
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> settings.move.<span class="keyword">nil</span>?
|
195
|
+
file = file.move!(settings.dest_path, {}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
196
|
+
button = settings.move
|
197
|
+
<span class="keyword">end</span></pre></div></div>
|
198
|
+
|
199
|
+
</li>
|
200
|
+
|
201
|
+
|
202
|
+
<li id="section-11">
|
203
|
+
<div class="annotation">
|
204
|
+
|
205
|
+
<div class="pilwrap ">
|
206
|
+
<a class="pilcrow" href="#section-11">¶</a>
|
207
|
+
</div>
|
208
|
+
<p>result message</p>
|
209
|
+
|
210
|
+
</div>
|
211
|
+
|
212
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> file
|
213
|
+
massage = <span class="string">"File was <span class="subst">#{button}</span>'ed to the <span class="subst">#{settings.dest_path}</span> folder"</span>
|
214
|
+
<span class="keyword">end</span>
|
215
|
+
|
216
|
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
|
217
|
+
err = e.message
|
218
|
+
<span class="keyword">end</span></pre></div></div>
|
219
|
+
|
220
|
+
</li>
|
221
|
+
|
222
|
+
|
223
|
+
<li id="section-12">
|
224
|
+
<div class="annotation">
|
225
|
+
|
226
|
+
<div class="pilwrap ">
|
227
|
+
<a class="pilcrow" href="#section-12">¶</a>
|
228
|
+
</div>
|
229
|
+
<p>set variables for template</p>
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample5</span>, <span class="symbol">:locals</span> => {<span class="symbol">:userId</span> => settings.client_id, <span class="symbol">:privateKey</span> => settings.private_key, <span class="symbol">:file_id</span> => settings.file_id, <span class="symbol">:dest_path</span> => settings.dest_path, <span class="symbol">:massage</span> => massage, <span class="symbol">:err</span> => err}
|
234
|
+
<span class="keyword">end</span></pre></div></div>
|
235
|
+
|
236
|
+
</li>
|
237
|
+
|
238
|
+
</ul>
|
239
|
+
</div>
|
240
|
+
</body>
|
241
|
+
</html>
|