groupdocs 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +51 -0
- data/examples/api-samples/Gemfile +1 -1
- data/examples/api-samples/Gemfile.lock +43 -0
- data/examples/api-samples/public/docs/{sample2.html → sample01.html} +39 -19
- data/examples/api-samples/public/docs/{sample3.html → sample02.html} +28 -22
- data/examples/api-samples/public/docs/sample03.html +285 -0
- data/examples/api-samples/public/docs/{sample4.html → sample04.html} +30 -36
- data/examples/api-samples/public/docs/{sample5.html → sample05.html} +68 -31
- data/examples/api-samples/public/docs/sample06.html +299 -0
- data/examples/api-samples/public/docs/{sample7.html → sample07.html} +53 -18
- data/examples/api-samples/public/docs/{sample8.html → sample08.html} +64 -41
- data/examples/api-samples/public/docs/sample09.html +260 -0
- data/examples/api-samples/public/docs/sample10.html +67 -28
- data/examples/api-samples/public/docs/sample11.html +171 -55
- data/examples/api-samples/public/docs/sample12.html +53 -17
- data/examples/api-samples/public/docs/sample13.html +52 -16
- data/examples/api-samples/public/docs/sample14.html +51 -8
- data/examples/api-samples/public/docs/sample15.html +46 -10
- data/examples/api-samples/public/docs/sample16.html +81 -7
- data/examples/api-samples/public/docs/sample17.html +103 -15
- data/examples/api-samples/public/docs/sample18.html +117 -41
- data/examples/api-samples/public/docs/sample19.html +410 -36
- data/examples/api-samples/public/docs/sample20.html +46 -10
- data/examples/api-samples/public/docs/sample21.html +504 -45
- data/examples/api-samples/public/docs/sample22.html +166 -28
- data/examples/api-samples/public/docs/sample23.html +61 -25
- data/examples/api-samples/public/docs/sample24.html +100 -12
- data/examples/api-samples/public/docs/sample25.html +123 -49
- data/examples/api-samples/public/docs/sample26.html +41 -8
- data/examples/api-samples/public/docs/sample27.html +125 -50
- data/examples/api-samples/public/docs/sample28.html +27 -9
- data/examples/api-samples/public/docs/sample29.html +10 -10
- data/examples/api-samples/public/docs/sample30.html +70 -14
- data/examples/api-samples/public/docs/sample31.html +108 -67
- data/examples/api-samples/public/docs/sample32.html +71 -99
- data/examples/api-samples/public/docs/sample33.html +107 -32
- data/examples/api-samples/public/docs/{sample1.html → sample34.html} +58 -18
- data/examples/api-samples/public/docs/sample35.html +666 -0
- data/examples/api-samples/public/docs/{sample6.html → sample36.html} +56 -37
- data/examples/api-samples/public/docs/sample37.html +815 -0
- data/examples/api-samples/public/docs/sample38.html +508 -0
- data/examples/api-samples/public/docs/sample39.html +921 -0
- data/examples/api-samples/public/docs/sample40.html +510 -0
- data/examples/api-samples/public/docs/sample41.html +452 -0
- data/examples/api-samples/public/docs/sample42.html +311 -0
- data/examples/api-samples/public/templates/test_all_fields2.pdf +0 -0
- data/examples/api-samples/samples/sample01.rb +37 -0
- data/examples/api-samples/samples/sample02.rb +41 -0
- data/examples/api-samples/samples/sample03.rb +73 -0
- data/examples/api-samples/samples/sample04.rb +47 -0
- data/examples/api-samples/samples/{sample5.rb → sample05.rb} +26 -14
- data/examples/api-samples/samples/sample06.rb +80 -0
- data/examples/api-samples/samples/sample07.rb +52 -0
- data/examples/api-samples/samples/sample08.rb +69 -0
- data/examples/api-samples/samples/sample09.rb +83 -0
- data/examples/api-samples/samples/sample10.rb +29 -15
- data/examples/api-samples/samples/sample11.rb +89 -37
- data/examples/api-samples/samples/sample12.rb +22 -11
- data/examples/api-samples/samples/sample13.rb +22 -10
- data/examples/api-samples/samples/sample14.rb +23 -5
- data/examples/api-samples/samples/sample15.rb +18 -7
- data/examples/api-samples/samples/sample16.rb +28 -4
- data/examples/api-samples/samples/sample17.rb +31 -5
- data/examples/api-samples/samples/sample18.rb +36 -8
- data/examples/api-samples/samples/sample19.rb +138 -18
- data/examples/api-samples/samples/sample20.rb +14 -3
- data/examples/api-samples/samples/sample21.rb +162 -23
- data/examples/api-samples/samples/sample22.rb +73 -22
- data/examples/api-samples/samples/sample23.rb +17 -6
- data/examples/api-samples/samples/sample24.rb +34 -7
- data/examples/api-samples/samples/sample25.rb +37 -12
- data/examples/api-samples/samples/sample26.rb +12 -5
- data/examples/api-samples/samples/sample27.rb +38 -12
- data/examples/api-samples/samples/sample28.rb +25 -6
- data/examples/api-samples/samples/sample29.rb +12 -12
- data/examples/api-samples/samples/sample30.rb +27 -15
- data/examples/api-samples/samples/sample31.rb +44 -33
- data/examples/api-samples/samples/sample32.rb +43 -41
- data/examples/api-samples/samples/sample33.rb +42 -14
- data/examples/api-samples/samples/sample34.rb +40 -0
- data/examples/api-samples/samples/sample35.rb +224 -0
- data/examples/api-samples/samples/sample36.rb +58 -0
- data/examples/api-samples/samples/sample37.rb +229 -0
- data/examples/api-samples/samples/sample38.rb +128 -0
- data/examples/api-samples/samples/sample39.rb +252 -0
- data/examples/api-samples/samples/sample40.rb +164 -0
- data/examples/api-samples/samples/sample41.rb +118 -0
- data/examples/api-samples/samples/sample42.rb +97 -0
- data/examples/api-samples/views/_others_samples.haml +25 -11
- data/examples/api-samples/views/index.haml +23 -11
- data/examples/api-samples/views/popup.haml +32 -0
- data/examples/api-samples/views/{sample1.haml → sample01.haml} +12 -7
- data/examples/api-samples/views/{sample2.haml → sample02.haml} +20 -15
- data/examples/api-samples/views/sample03.haml +83 -0
- data/examples/api-samples/views/sample04.haml +49 -0
- data/examples/api-samples/views/{sample5.haml → sample05.haml} +19 -14
- data/examples/api-samples/views/sample06.haml +53 -0
- data/examples/api-samples/views/sample07.haml +47 -0
- data/examples/api-samples/views/{sample8.haml → sample08.haml} +17 -12
- data/examples/api-samples/views/{sample9.haml → sample09.haml} +19 -4
- data/examples/api-samples/views/sample10.haml +18 -13
- data/examples/api-samples/views/sample11.haml +48 -19
- data/examples/api-samples/views/sample12.haml +26 -21
- data/examples/api-samples/views/sample13.haml +18 -12
- data/examples/api-samples/views/sample14.haml +21 -15
- data/examples/api-samples/views/sample15.haml +16 -9
- data/examples/api-samples/views/sample16.haml +18 -5
- data/examples/api-samples/views/sample17.haml +14 -9
- data/examples/api-samples/views/sample18.haml +13 -7
- data/examples/api-samples/views/sample19.haml +37 -8
- data/examples/api-samples/views/sample20.haml +13 -8
- data/examples/api-samples/views/sample21.haml +71 -13
- data/examples/api-samples/views/sample22.haml +53 -16
- data/examples/api-samples/views/sample23.haml +9 -4
- data/examples/api-samples/views/sample24.haml +9 -4
- data/examples/api-samples/views/sample25.haml +18 -13
- data/examples/api-samples/views/sample26.haml +8 -3
- data/examples/api-samples/views/sample27.haml +20 -14
- data/examples/api-samples/views/sample28.haml +16 -10
- data/examples/api-samples/views/sample29.haml +4 -4
- data/examples/api-samples/views/sample30.haml +16 -10
- data/examples/api-samples/views/sample31.haml +39 -32
- data/examples/api-samples/views/sample32.haml +25 -36
- data/examples/api-samples/views/sample33.haml +14 -17
- data/examples/api-samples/views/sample34.haml +48 -0
- data/examples/api-samples/views/sample35.haml +95 -0
- data/examples/api-samples/views/sample36.haml +64 -0
- data/examples/api-samples/views/sample37.haml +124 -0
- data/examples/api-samples/views/sample38.haml +115 -0
- data/examples/api-samples/views/sample39.haml +236 -0
- data/examples/api-samples/views/sample40.haml +95 -0
- data/examples/api-samples/views/{sample4.haml → sample41.haml} +90 -72
- data/examples/api-samples/views/sample42.haml +59 -0
- data/lib/groupdocs/api/helpers/rest_helper.rb +13 -1
- data/lib/groupdocs/datasource.rb +2 -1
- data/lib/groupdocs/document.rb +101 -13
- data/lib/groupdocs/document/annotation.rb +28 -13
- data/lib/groupdocs/document/annotation/marker.rb +18 -0
- data/lib/groupdocs/document/annotation/reply.rb +9 -2
- data/lib/groupdocs/document/field.rb +5 -1
- data/lib/groupdocs/job.rb +12 -2
- data/lib/groupdocs/questionnaire.rb +174 -4
- data/lib/groupdocs/questionnaire/collector.rb +21 -0
- data/lib/groupdocs/questionnaire/question.rb +19 -0
- data/lib/groupdocs/questionnaire/question/answer.rb +5 -0
- data/lib/groupdocs/questionnaire/question/conditions.rb +20 -0
- data/lib/groupdocs/signature.rb +36 -308
- data/lib/groupdocs/signature/envelope.rb +146 -4
- data/lib/groupdocs/signature/field.rb +20 -1
- data/lib/groupdocs/signature/field/location.rb +18 -7
- data/lib/groupdocs/signature/form.rb +199 -10
- data/lib/groupdocs/signature/shared/document_methods.rb +38 -0
- data/lib/groupdocs/signature/shared/entity_methods.rb +0 -1
- data/lib/groupdocs/signature/shared/field_methods.rb +13 -38
- data/lib/groupdocs/signature/shared/recipient_methods.rb +8 -0
- data/lib/groupdocs/signature/template.rb +3 -1
- data/lib/groupdocs/storage.rb +4 -1
- data/lib/groupdocs/storage/file.rb +18 -1
- data/lib/groupdocs/subscription.rb +8 -3
- data/lib/groupdocs/user.rb +8 -0
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/document/annotation_spec.rb +1 -14
- data/spec/groupdocs/subscription_spec.rb +2 -2
- metadata +86 -32
- checksums.yaml +0 -15
- data/examples/api-samples/public/docs/sample9.html +0 -200
- data/examples/api-samples/samples/sample1.rb +0 -25
- data/examples/api-samples/samples/sample2.rb +0 -29
- data/examples/api-samples/samples/sample3.rb +0 -33
- data/examples/api-samples/samples/sample4.rb +0 -51
- data/examples/api-samples/samples/sample6.rb +0 -49
- data/examples/api-samples/samples/sample7.rb +0 -42
- data/examples/api-samples/samples/sample8.rb +0 -61
- data/examples/api-samples/samples/sample9.rb +0 -48
- data/examples/api-samples/views/sample3.haml +0 -44
- data/examples/api-samples/views/sample6.haml +0 -49
- data/examples/api-samples/views/sample7.haml +0 -42
Binary file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample01' do
|
3
|
+
haml :sample01
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample01' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :base_path, params[:basePath]
|
12
|
+
|
13
|
+
begin
|
14
|
+
|
15
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
16
|
+
|
17
|
+
# Configure your access to API server
|
18
|
+
GroupDocs.configure do |groupdocs|
|
19
|
+
groupdocs.client_id = settings.client_id
|
20
|
+
groupdocs.private_key = settings.private_key
|
21
|
+
# Optionally specify API server and version
|
22
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
23
|
+
end
|
24
|
+
|
25
|
+
# check required variables
|
26
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
27
|
+
|
28
|
+
# make a request to API using client_id and private_key
|
29
|
+
user = GroupDocs::User.get!()
|
30
|
+
|
31
|
+
rescue Exception => e
|
32
|
+
err = e.message
|
33
|
+
end
|
34
|
+
|
35
|
+
# set variables for template
|
36
|
+
haml :sample01, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :user => user, :err => err}
|
37
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample02' do
|
3
|
+
haml :sample02
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample02' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :base_path, params[:basePath]
|
12
|
+
|
13
|
+
begin
|
14
|
+
|
15
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
16
|
+
|
17
|
+
# Configure your access to API server
|
18
|
+
GroupDocs.configure do |groupdocs|
|
19
|
+
groupdocs.client_id = settings.client_id
|
20
|
+
groupdocs.private_key = settings.private_key
|
21
|
+
# Optionally specify API server and version
|
22
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
23
|
+
end
|
24
|
+
|
25
|
+
# Check required variables
|
26
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
27
|
+
|
28
|
+
# Make a request to API using client_id and private_key
|
29
|
+
files_list = GroupDocs::Storage::Folder.list!('/', {})
|
30
|
+
|
31
|
+
# Construct list of files
|
32
|
+
filelist = ''
|
33
|
+
files_list.each { |element| filelist << "#{element.name}<br />" }
|
34
|
+
|
35
|
+
rescue Exception => e
|
36
|
+
err = e.message
|
37
|
+
end
|
38
|
+
|
39
|
+
# Set variables for template
|
40
|
+
haml :sample02, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err}
|
41
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample03' do
|
3
|
+
haml :sample03
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample03' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :source, params[:source]
|
12
|
+
set :url, params[:url]
|
13
|
+
set :folder_path, params[:folderPath]
|
14
|
+
set :callback, params[:callback]
|
15
|
+
set :base_path, params[:basePath]
|
16
|
+
|
17
|
+
begin
|
18
|
+
# Check required variables
|
19
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
20
|
+
|
21
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
22
|
+
|
23
|
+
# Configure your access to API server
|
24
|
+
GroupDocs.configure do |groupdocs|
|
25
|
+
groupdocs.client_id = settings.client_id
|
26
|
+
groupdocs.private_key = settings.private_key
|
27
|
+
# Optionally specify API server and version
|
28
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get document by file GUID
|
32
|
+
case settings.source
|
33
|
+
|
34
|
+
when 'file'
|
35
|
+
# Construct path
|
36
|
+
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
37
|
+
# Open file
|
38
|
+
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
39
|
+
# Make a request to API using client_id and private_key
|
40
|
+
file = GroupDocs::Storage::File.upload!(filepath, {path: settings.folder_path, callbackUrl: settings.callback})
|
41
|
+
|
42
|
+
when 'url'
|
43
|
+
|
44
|
+
# Upload file from defined url
|
45
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
46
|
+
else raise 'Wrong GUID source.'
|
47
|
+
end
|
48
|
+
|
49
|
+
#Get url from request
|
50
|
+
case settings.base_path
|
51
|
+
|
52
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
53
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{file.guid}"
|
54
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
55
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{file.guid}"
|
56
|
+
else
|
57
|
+
url = "https://apps.groupdocs.com/document-viewer/embed/#{file.guid}"
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Add the signature in url
|
62
|
+
url = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
63
|
+
|
64
|
+
# Set iframe with document GUID
|
65
|
+
iframe = "<iframe src='#{url}' frameborder='0' width='720' height='600'></iframe>"
|
66
|
+
|
67
|
+
rescue Exception => e
|
68
|
+
err = e.message
|
69
|
+
end
|
70
|
+
|
71
|
+
# set variables for template
|
72
|
+
haml :sample03, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :err => err}
|
73
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample04' do
|
3
|
+
haml :sample04
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample04' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :file_id, params[:fileId]
|
12
|
+
set :url, params[:url]
|
13
|
+
set :base_path, params[:basePath]
|
14
|
+
|
15
|
+
begin
|
16
|
+
# Check required variables
|
17
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
|
18
|
+
|
19
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
20
|
+
|
21
|
+
# Configure your access to API server
|
22
|
+
GroupDocs.configure do |groupdocs|
|
23
|
+
groupdocs.client_id = settings.client_id
|
24
|
+
groupdocs.private_key = settings.private_key
|
25
|
+
# Optionally specify API server and version
|
26
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get file GUID
|
30
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id}).to_document
|
31
|
+
|
32
|
+
# Obtaining all Metadata for file
|
33
|
+
document = file.metadata!
|
34
|
+
file = document.last_view.document.file
|
35
|
+
# Download file
|
36
|
+
dowloaded_file = file.download!("#{File.dirname(__FILE__)}/../public/downloads")
|
37
|
+
unless dowloaded_file.empty?
|
38
|
+
massage = "<font color='green'>File was downloaded to the <font color='blue'>#{dowloaded_file}</font> folder</font> <br />"
|
39
|
+
end
|
40
|
+
|
41
|
+
rescue Exception => e
|
42
|
+
err = e.message
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set variables for template
|
46
|
+
haml :sample04, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :massage => massage, :err => err}
|
47
|
+
end
|
@@ -1,58 +1,70 @@
|
|
1
1
|
# GET request
|
2
|
-
get '/
|
3
|
-
haml :
|
2
|
+
get '/sample05' do
|
3
|
+
haml :sample05
|
4
4
|
end
|
5
5
|
|
6
6
|
# POST request
|
7
|
-
post '/
|
7
|
+
post '/sample05' do
|
8
8
|
# set variables
|
9
|
-
set :client_id, params[:
|
10
|
-
set :private_key, params[:
|
11
|
-
set :file_id, params[:
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :file_id, params[:srcPath]
|
12
12
|
set :url, params[:url]
|
13
13
|
set :copy, params[:copy]
|
14
14
|
set :move, params[:move]
|
15
|
-
set :dest_path, params[:
|
15
|
+
set :dest_path, params[:destPath]
|
16
16
|
set :source, params[:source]
|
17
|
+
set :base_path, params[:basePath]
|
17
18
|
|
18
19
|
begin
|
19
20
|
|
20
21
|
# check required variables
|
21
22
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
22
23
|
|
24
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
25
|
+
|
26
|
+
# Configure your access to API server
|
27
|
+
GroupDocs.configure do |groupdocs|
|
28
|
+
groupdocs.client_id = settings.client_id
|
29
|
+
groupdocs.private_key = settings.private_key
|
30
|
+
# Optionally specify API server and version
|
31
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
32
|
+
end
|
33
|
+
|
23
34
|
file = nil
|
24
35
|
# get document by file GUID
|
25
36
|
case settings.source
|
26
37
|
when 'guid'
|
27
|
-
file = GroupDocs::Storage::File.new({:guid => settings.file_id})
|
38
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id}).to_document.metadata!()
|
39
|
+
file = file.last_view.document.file
|
28
40
|
when 'local'
|
29
41
|
# construct path
|
30
42
|
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
31
43
|
# open file
|
32
44
|
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
33
45
|
# make a request to API using client_id and private_key
|
34
|
-
file = GroupDocs::Storage::File.upload!(filepath, {}
|
46
|
+
file = GroupDocs::Storage::File.upload!(filepath, {})
|
35
47
|
when 'url'
|
36
|
-
file = GroupDocs::Storage::File.upload_web!(settings.url
|
48
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
37
49
|
else
|
38
50
|
raise 'Wrong GUID source.'
|
39
51
|
end
|
40
52
|
# raise files_list.to_yaml
|
41
53
|
# copy file using request to API
|
42
54
|
unless settings.copy.nil?
|
43
|
-
file = file.copy!(settings.dest_path, {}
|
55
|
+
file = file.copy!(settings.dest_path, {})
|
44
56
|
button = settings.copy
|
45
57
|
end
|
46
58
|
|
47
59
|
# move file using request to API
|
48
60
|
unless settings.move.nil?
|
49
|
-
file = file.move!(settings.dest_path, {}
|
61
|
+
file = file.move!(settings.dest_path, {})
|
50
62
|
button = settings.move
|
51
63
|
end
|
52
64
|
|
53
65
|
# result message
|
54
66
|
if file
|
55
|
-
massage = "File was #{button}'ed to the
|
67
|
+
massage = "File was #{button}'ed to the <font color=\"blue\">#{settings.dest_path}</font> folder"
|
56
68
|
end
|
57
69
|
|
58
70
|
rescue Exception => e
|
@@ -60,5 +72,5 @@ post '/sample5' do
|
|
60
72
|
end
|
61
73
|
|
62
74
|
# set variables for template
|
63
|
-
haml :
|
75
|
+
haml :sample05, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :destPath => settings.dest_path, :massage => massage, :err => err}
|
64
76
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample06' do
|
3
|
+
haml :sample06
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample06' do
|
8
|
+
# set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :base_path, params[:basePath]
|
12
|
+
require 'net/http'
|
13
|
+
|
14
|
+
begin
|
15
|
+
# Check required variables
|
16
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
17
|
+
|
18
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
19
|
+
|
20
|
+
# Configure your access to API server
|
21
|
+
GroupDocs.configure do |groupdocs|
|
22
|
+
groupdocs.client_id = settings.client_id
|
23
|
+
groupdocs.private_key = settings.private_key
|
24
|
+
# Optionally specify API server and version
|
25
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# Construct file path and open file
|
30
|
+
file_one_path = "#{File.dirname(__FILE__)}/#{params[:fiDocument][:filename]}"
|
31
|
+
File.open(file_one_path, 'wb') { |f| f.write(params[:fiDocument][:tempfile].read) }
|
32
|
+
|
33
|
+
|
34
|
+
# Create new file
|
35
|
+
file_one = GroupDocs::Storage::File.new(name: params[:fiDocument][:filename], local_path: file_one_path)
|
36
|
+
document_one = file_one.to_document
|
37
|
+
|
38
|
+
# Construct signature path and open file
|
39
|
+
signature_one_path = "#{Dir.tmpdir}/#{params[:fiSignature][:filename]}"
|
40
|
+
File.open(signature_one_path, 'wb') { |f| f.write(params[:fiSignature][:tempfile].read) }
|
41
|
+
|
42
|
+
# Add signature to file using API
|
43
|
+
signature_one = GroupDocs::Signature.new(name: params[:fiSignature][:filename], image_path: signature_one_path)
|
44
|
+
signature_one.position = {top: 0.83319, left: 0.72171, width: 100, height: 40}
|
45
|
+
|
46
|
+
|
47
|
+
# Make a request to API using client_id and private_key
|
48
|
+
signed_documents = GroupDocs::Document.sign_documents!([document_one], [signature_one], {})
|
49
|
+
sleep(5)
|
50
|
+
|
51
|
+
# Get the document guid
|
52
|
+
document = GroupDocs::Signature.sign_document_status!(signed_documents)
|
53
|
+
|
54
|
+
# Create request from servers
|
55
|
+
case settings.base_path
|
56
|
+
|
57
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
58
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{document.guid}"
|
59
|
+
|
60
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
61
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{document.guid}"
|
62
|
+
else
|
63
|
+
url = "https://apps.groupdocs.com/document-viewer/embed/#{document.guid}"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Add the signature to url request
|
67
|
+
iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
68
|
+
|
69
|
+
# Generate result
|
70
|
+
if signed_documents
|
71
|
+
iframe = "<iframe src='#{iframe}' frameborder='0' width='720' height='600'></iframe>"
|
72
|
+
end
|
73
|
+
|
74
|
+
rescue Exception => e
|
75
|
+
err = e.message
|
76
|
+
end
|
77
|
+
|
78
|
+
# Set variables for template
|
79
|
+
haml :sample06, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :err => err}
|
80
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample07' do
|
3
|
+
haml :sample07
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample07' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :base_path, params[:basePath]
|
12
|
+
|
13
|
+
begin
|
14
|
+
# Check required variables
|
15
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
16
|
+
|
17
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
18
|
+
|
19
|
+
# Configure your access to API server
|
20
|
+
GroupDocs.configure do |groupdocs|
|
21
|
+
groupdocs.client_id = settings.client_id
|
22
|
+
groupdocs.private_key = settings.private_key
|
23
|
+
# Optionally specify API server and version
|
24
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Make a request to API using client_id and private_key
|
28
|
+
files_list = GroupDocs::Storage::Folder.list!('/', {:extended => true}, {:client_id => settings.client_id, :private_key => settings.private_key})
|
29
|
+
|
30
|
+
# Construct result string
|
31
|
+
thumbnails = ''
|
32
|
+
files_list.each do |element|
|
33
|
+
if element.class.name.split('::').last == 'Folder'
|
34
|
+
next
|
35
|
+
end
|
36
|
+
if element.thumbnail
|
37
|
+
name = element.name
|
38
|
+
thumbnails += "<p><img src='data:image/png;base64,#{element.thumbnail}', width='40px', height='40px'> #{name}</p>"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
unless thumbnails.empty?
|
43
|
+
set :thumbnails, thumbnails
|
44
|
+
end
|
45
|
+
|
46
|
+
rescue Exception => e
|
47
|
+
err = e.message
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set variables for template
|
51
|
+
haml :sample07, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :thumbnailList => thumbnails, :err => err}
|
52
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample08' do
|
3
|
+
haml :sample08
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample08' do
|
8
|
+
# Set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :guid, params[:guid]
|
12
|
+
set :page_number, params[:pageNumber]
|
13
|
+
set :source, params[:source]
|
14
|
+
set :file_id, params[:fileId]
|
15
|
+
set :base_path, params[:basePath]
|
16
|
+
|
17
|
+
begin
|
18
|
+
# Check required variables
|
19
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
20
|
+
|
21
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
22
|
+
|
23
|
+
# Configure your access to API server
|
24
|
+
GroupDocs.configure do |groupdocs|
|
25
|
+
groupdocs.client_id = settings.client_id
|
26
|
+
groupdocs.private_key = settings.private_key
|
27
|
+
# Optionally specify API server and version
|
28
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
29
|
+
end
|
30
|
+
|
31
|
+
file = nil
|
32
|
+
doc = nil
|
33
|
+
metadata = nil
|
34
|
+
|
35
|
+
# Get document by file GUID
|
36
|
+
case settings.source
|
37
|
+
when 'guid'
|
38
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id})
|
39
|
+
when 'local'
|
40
|
+
# Construct path
|
41
|
+
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
42
|
+
# Open file
|
43
|
+
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
44
|
+
# Make a request to API using client_id and private_key
|
45
|
+
file = GroupDocs::Storage::File.upload!(filepath, {})
|
46
|
+
when 'url'
|
47
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
48
|
+
else
|
49
|
+
raise 'Wrong GUID source.'
|
50
|
+
end
|
51
|
+
|
52
|
+
doc = file.to_document
|
53
|
+
metadata = doc.metadata!()
|
54
|
+
|
55
|
+
# Get document page images
|
56
|
+
images = doc.page_images!(800, 400, {:first_page => 0, :page_count => metadata.views_count})
|
57
|
+
|
58
|
+
# Result
|
59
|
+
unless images.empty?
|
60
|
+
image = images[Integer(settings.page_number)]
|
61
|
+
end
|
62
|
+
|
63
|
+
rescue Exception => e
|
64
|
+
err = e.message
|
65
|
+
end
|
66
|
+
|
67
|
+
# Set variables for template
|
68
|
+
haml :sample08, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :guid => settings.guid, :pageNumber => settings.page_number, :image => image, :err => err}
|
69
|
+
end
|