groupdocs 1.5.8 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/examples/api-samples/public/docs/sample01.html +34 -15
- data/examples/api-samples/public/docs/sample02.html +36 -15
- data/examples/api-samples/public/docs/sample03.html +55 -34
- data/examples/api-samples/public/docs/sample04.html +33 -14
- data/examples/api-samples/public/docs/sample05.html +51 -33
- data/examples/api-samples/public/docs/sample06.html +86 -40
- data/examples/api-samples/public/docs/sample07.html +32 -13
- data/examples/api-samples/public/docs/sample08.html +39 -20
- data/examples/api-samples/public/docs/sample09.html +93 -39
- data/examples/api-samples/public/docs/sample10.html +39 -21
- data/examples/api-samples/public/docs/sample11.html +133 -88
- data/examples/api-samples/public/docs/sample12.html +33 -14
- data/examples/api-samples/public/docs/sample13.html +14 -7
- data/examples/api-samples/public/docs/sample14.html +37 -18
- data/examples/api-samples/public/docs/sample15.html +29 -10
- data/examples/api-samples/public/docs/sample16.html +58 -25
- data/examples/api-samples/public/docs/sample17.html +71 -38
- data/examples/api-samples/public/docs/sample18.html +98 -71
- data/examples/api-samples/public/docs/sample19.html +74 -42
- data/examples/api-samples/public/docs/sample20.html +39 -21
- data/examples/api-samples/public/docs/sample21.html +113 -69
- data/examples/api-samples/public/docs/sample22.html +89 -43
- data/examples/api-samples/public/docs/sample23.html +50 -32
- data/examples/api-samples/public/docs/sample24.html +64 -31
- data/examples/api-samples/public/docs/sample25.html +107 -60
- data/examples/api-samples/public/docs/sample26.html +29 -10
- data/examples/api-samples/public/docs/sample27.html +107 -61
- data/examples/api-samples/public/docs/sample28.html +158 -9
- data/examples/api-samples/public/docs/sample29.html +13 -8
- data/examples/api-samples/public/docs/sample30.html +34 -15
- data/examples/api-samples/public/docs/sample31.html +107 -76
- data/examples/api-samples/public/docs/sample32.html +104 -40
- data/examples/api-samples/public/docs/sample33.html +85 -36
- data/examples/api-samples/public/docs/sample34.html +30 -11
- data/examples/api-samples/public/docs/sample35.html +90 -27
- data/examples/api-samples/public/docs/sample36.html +36 -16
- data/examples/api-samples/public/docs/sample37.html +144 -265
- data/examples/api-samples/public/docs/sample38.html +113 -64
- data/examples/api-samples/public/docs/sample39.html +118 -45
- data/examples/api-samples/public/docs/sample40.html +81 -46
- data/examples/api-samples/public/docs/sample41.html +562 -90
- data/examples/api-samples/public/docs/sample42.html +94 -39
- data/examples/api-samples/public/docs/sample43.html +669 -0
- data/examples/api-samples/samples/sample01.rb +17 -10
- data/examples/api-samples/samples/sample02.rb +21 -12
- data/examples/api-samples/samples/sample03.rb +35 -29
- data/examples/api-samples/samples/sample04.rb +19 -12
- data/examples/api-samples/samples/sample05.rb +24 -17
- data/examples/api-samples/samples/sample06.rb +38 -32
- data/examples/api-samples/samples/sample07.rb +19 -12
- data/examples/api-samples/samples/sample08.rb +22 -15
- data/examples/api-samples/samples/sample09.rb +31 -29
- data/examples/api-samples/samples/sample10.rb +22 -15
- data/examples/api-samples/samples/sample11.rb +78 -81
- data/examples/api-samples/samples/sample12.rb +19 -21
- data/examples/api-samples/samples/sample13.rb +19 -21
- data/examples/api-samples/samples/sample14.rb +18 -12
- data/examples/api-samples/samples/sample15.rb +17 -10
- data/examples/api-samples/samples/sample16.rb +25 -17
- data/examples/api-samples/samples/sample17.rb +31 -23
- data/examples/api-samples/samples/sample18.rb +60 -55
- data/examples/api-samples/samples/sample19.rb +48 -42
- data/examples/api-samples/samples/sample20.rb +20 -13
- data/examples/api-samples/samples/sample21.rb +62 -54
- data/examples/api-samples/samples/sample22.rb +37 -31
- data/examples/api-samples/samples/sample23.rb +24 -17
- data/examples/api-samples/samples/sample24.rb +29 -22
- data/examples/api-samples/samples/sample25.rb +47 -40
- data/examples/api-samples/samples/sample26.rb +16 -9
- data/examples/api-samples/samples/sample27.rb +46 -39
- data/examples/api-samples/samples/sample28.rb +42 -11
- data/examples/api-samples/samples/sample29.rb +13 -8
- data/examples/api-samples/samples/sample30.rb +19 -12
- data/examples/api-samples/samples/sample31.rb +63 -58
- data/examples/api-samples/samples/sample32.rb +45 -42
- data/examples/api-samples/samples/sample33.rb +36 -25
- data/examples/api-samples/samples/sample34.rb +16 -9
- data/examples/api-samples/samples/sample35.rb +66 -53
- data/examples/api-samples/samples/sample36.rb +19 -15
- data/examples/api-samples/samples/sample37.rb +61 -99
- data/examples/api-samples/samples/sample38.rb +51 -43
- data/examples/api-samples/samples/sample39.rb +78 -62
- data/examples/api-samples/samples/sample40.rb +48 -38
- data/examples/api-samples/samples/sample41.rb +189 -67
- data/examples/api-samples/samples/sample42.rb +37 -29
- data/examples/api-samples/samples/sample43.rb +127 -0
- data/examples/api-samples/views/_others_samples.haml +4 -2
- data/examples/api-samples/views/index.haml +4 -2
- data/examples/api-samples/views/sample11.haml +1 -1
- data/examples/api-samples/views/sample28.haml +8 -0
- data/examples/api-samples/views/sample31.haml +1 -6
- data/examples/api-samples/views/sample39.haml +7 -2
- data/examples/api-samples/views/sample41.haml +78 -33
- data/examples/api-samples/views/sample42.haml +0 -1
- data/examples/api-samples/views/sample43.haml +91 -0
- data/lib/groupdocs/api/helpers/access_rights_helper.rb +6 -5
- data/lib/groupdocs/api/helpers/url_helper.rb +2 -1
- data/lib/groupdocs/document.rb +3 -3
- data/lib/groupdocs/version.rb +1 -1
- metadata +5 -2
@@ -1,37 +1,44 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample01' do
|
3
3
|
haml :sample01
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample01' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :base_path, params[:basePath]
|
12
12
|
|
13
13
|
begin
|
14
14
|
|
15
|
-
|
15
|
+
#Prepare base path
|
16
|
+
if settings.base_path.empty?
|
17
|
+
base_path = 'https://api.groupdocs.com'
|
18
|
+
elsif settings.base_path.match('/v2.0')
|
19
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
20
|
+
else
|
21
|
+
base_path = settings.base_path
|
22
|
+
end
|
16
23
|
|
17
|
-
#
|
24
|
+
#Configure your access to API server
|
18
25
|
GroupDocs.configure do |groupdocs|
|
19
26
|
groupdocs.client_id = settings.client_id
|
20
27
|
groupdocs.private_key = settings.private_key
|
21
|
-
#
|
22
|
-
groupdocs.api_server =
|
28
|
+
#Optionally specify API server and version
|
29
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
23
30
|
end
|
24
31
|
|
25
|
-
#
|
32
|
+
#Check required variables
|
26
33
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
27
34
|
|
28
|
-
#
|
35
|
+
#Make a request to API using client_id and private_key
|
29
36
|
user = GroupDocs::User.get!()
|
30
37
|
|
31
38
|
rescue Exception => e
|
32
39
|
err = e.message
|
33
40
|
end
|
34
41
|
|
35
|
-
#
|
42
|
+
#Set variables for template
|
36
43
|
haml :sample01, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :user => user, :err => err}
|
37
44
|
end
|
@@ -1,41 +1,50 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample02' do
|
3
3
|
haml :sample02
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample02' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :base_path, params[:basePath]
|
12
12
|
|
13
13
|
begin
|
14
14
|
|
15
|
-
|
15
|
+
#Prepare base path
|
16
|
+
if settings.base_path.empty?
|
17
|
+
base_path = 'https://api.groupdocs.com'
|
18
|
+
elsif settings.base_path.match('/v2.0')
|
19
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
20
|
+
else
|
21
|
+
base_path = settings.base_path
|
22
|
+
end
|
16
23
|
|
17
|
-
#
|
24
|
+
#Configure your access to API server
|
18
25
|
GroupDocs.configure do |groupdocs|
|
19
26
|
groupdocs.client_id = settings.client_id
|
20
27
|
groupdocs.private_key = settings.private_key
|
21
|
-
#
|
22
|
-
groupdocs.api_server =
|
28
|
+
#Optionally specify API server and version
|
29
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
23
30
|
end
|
24
31
|
|
25
|
-
#
|
32
|
+
#Check required variables
|
26
33
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
27
34
|
|
28
|
-
#
|
35
|
+
#Make a request to API using client_id and private_key
|
29
36
|
files_list = GroupDocs::Storage::Folder.list!('/', {})
|
30
37
|
|
31
|
-
#
|
38
|
+
#Construct list of files
|
32
39
|
filelist = ''
|
33
|
-
files_list.each
|
40
|
+
files_list.each do |element|
|
41
|
+
if element.class.name.split('::').last == 'File' then filelist << "#{element.name}<br />" end
|
42
|
+
end
|
34
43
|
|
35
44
|
rescue Exception => e
|
36
45
|
err = e.message
|
37
46
|
end
|
38
47
|
|
39
|
-
#
|
48
|
+
#Set variables for template
|
40
49
|
haml :sample02, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err}
|
41
50
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample03' do
|
3
3
|
haml :sample03
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample03' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :source, params[:source]
|
@@ -15,59 +15,65 @@ post '/sample03' do
|
|
15
15
|
set :base_path, params[:basePath]
|
16
16
|
|
17
17
|
begin
|
18
|
-
#
|
18
|
+
#Check required variables
|
19
19
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
20
20
|
|
21
|
-
|
21
|
+
#Prepare base path
|
22
|
+
if settings.base_path.empty?
|
23
|
+
base_path = 'https://api.groupdocs.com'
|
24
|
+
elsif settings.base_path.match('/v2.0')
|
25
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
26
|
+
else
|
27
|
+
base_path = settings.base_path
|
28
|
+
end
|
22
29
|
|
23
|
-
#
|
30
|
+
#Configure your access to API server
|
24
31
|
GroupDocs.configure do |groupdocs|
|
25
32
|
groupdocs.client_id = settings.client_id
|
26
33
|
groupdocs.private_key = settings.private_key
|
27
|
-
#
|
28
|
-
groupdocs.api_server =
|
34
|
+
#Optionally specify API server and version
|
35
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
29
36
|
end
|
30
37
|
|
31
|
-
#
|
38
|
+
#Get document by file GUID
|
32
39
|
case settings.source
|
33
40
|
|
34
41
|
when 'file'
|
35
|
-
#
|
42
|
+
#Construct path
|
36
43
|
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
37
|
-
#
|
44
|
+
#Open file
|
38
45
|
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
39
|
-
#
|
46
|
+
#Make a request to API using client_id and private_key
|
40
47
|
file = GroupDocs::Storage::File.upload!(filepath, {path: settings.folder_path, callbackUrl: settings.callback})
|
41
48
|
|
42
49
|
when 'url'
|
43
50
|
|
44
|
-
#
|
51
|
+
#Upload file from defined url
|
45
52
|
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
46
53
|
else raise 'Wrong GUID source.'
|
47
54
|
end
|
48
55
|
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
#Prepare to sign url
|
57
|
+
iframe = "/document-viewer/embed/#{file.guid}"
|
58
|
+
# Construct result string
|
59
|
+
url = GroupDocs::Api::Request.new(:path => iframe).prepare_and_sign_url
|
60
|
+
#Generate iframe URL
|
61
|
+
case base_path
|
62
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
63
|
+
iframe = "https://stage-api-groupdocs.dynabic.com#{url}"
|
64
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
65
|
+
iframe = "https://dev-apps.groupdocs.com#{url}"
|
66
|
+
else
|
67
|
+
iframe = "https://apps.groupdocs.com#{url}"
|
58
68
|
end
|
59
69
|
|
60
|
-
|
61
|
-
|
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>"
|
70
|
+
#Set iframe with document GUID
|
71
|
+
iframe = "<iframe src='#{iframe}' frameborder='0' width='720' height='600'></iframe>"
|
66
72
|
|
67
73
|
rescue Exception => e
|
68
74
|
err = e.message
|
69
75
|
end
|
70
76
|
|
71
|
-
#
|
77
|
+
#Set variables for template
|
72
78
|
haml :sample03, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :err => err}
|
73
79
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample04' do
|
3
3
|
haml :sample04
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample04' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :file_id, params[:fileId]
|
@@ -13,26 +13,33 @@ post '/sample04' do
|
|
13
13
|
set :base_path, params[:basePath]
|
14
14
|
|
15
15
|
begin
|
16
|
-
#
|
16
|
+
#Check required variables
|
17
17
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
|
18
18
|
|
19
|
-
|
19
|
+
#Prepare base path
|
20
|
+
if settings.base_path.empty?
|
21
|
+
base_path = 'https://api.groupdocs.com'
|
22
|
+
elsif settings.base_path.match('/v2.0')
|
23
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
24
|
+
else
|
25
|
+
base_path = settings.base_path
|
26
|
+
end
|
20
27
|
|
21
|
-
#
|
28
|
+
#Configure your access to API server
|
22
29
|
GroupDocs.configure do |groupdocs|
|
23
30
|
groupdocs.client_id = settings.client_id
|
24
31
|
groupdocs.private_key = settings.private_key
|
25
|
-
#
|
26
|
-
groupdocs.api_server =
|
32
|
+
#Optionally specify API server and version
|
33
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
27
34
|
end
|
28
35
|
|
29
|
-
#
|
36
|
+
#Get file GUID
|
30
37
|
file = GroupDocs::Storage::File.new({:guid => settings.file_id}).to_document
|
31
38
|
|
32
|
-
#
|
39
|
+
#Obtaining all Metadata for file
|
33
40
|
document = file.metadata!
|
34
41
|
file = document.last_view.document.file
|
35
|
-
#
|
42
|
+
#Download file
|
36
43
|
dowloaded_file = file.download!("#{File.dirname(__FILE__)}/../public/downloads")
|
37
44
|
unless dowloaded_file.empty?
|
38
45
|
massage = "<font color='green'>File was downloaded to the <font color='blue'>#{dowloaded_file}</font> folder</font> <br />"
|
@@ -42,6 +49,6 @@ post '/sample04' do
|
|
42
49
|
err = e.message
|
43
50
|
end
|
44
51
|
|
45
|
-
#
|
52
|
+
#Set variables for template
|
46
53
|
haml :sample04, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :massage => massage, :err => err}
|
47
54
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample05' do
|
3
3
|
haml :sample05
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample05' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :file_id, params[:srcPath]
|
@@ -18,51 +18,58 @@ post '/sample05' do
|
|
18
18
|
|
19
19
|
begin
|
20
20
|
|
21
|
-
#
|
21
|
+
#Check required variables
|
22
22
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
23
23
|
|
24
|
-
|
24
|
+
#Prepare base path
|
25
|
+
if settings.base_path.empty?
|
26
|
+
base_path = 'https://api.groupdocs.com'
|
27
|
+
elsif settings.base_path.match('/v2.0')
|
28
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
29
|
+
else
|
30
|
+
base_path = settings.base_path
|
31
|
+
end
|
25
32
|
|
26
|
-
#
|
33
|
+
#Configure your access to API server
|
27
34
|
GroupDocs.configure do |groupdocs|
|
28
35
|
groupdocs.client_id = settings.client_id
|
29
36
|
groupdocs.private_key = settings.private_key
|
30
|
-
#
|
31
|
-
groupdocs.api_server =
|
37
|
+
#Optionally specify API server and version
|
38
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
32
39
|
end
|
33
40
|
|
34
41
|
file = nil
|
35
|
-
#
|
42
|
+
#Get document by file GUID
|
36
43
|
case settings.source
|
37
44
|
when 'guid'
|
38
45
|
file = GroupDocs::Storage::File.new({:guid => settings.file_id}).to_document.metadata!()
|
39
46
|
file = file.last_view.document.file
|
40
47
|
when 'local'
|
41
|
-
#
|
48
|
+
#Construct path
|
42
49
|
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
43
|
-
#
|
50
|
+
#Open file
|
44
51
|
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
45
|
-
#
|
52
|
+
#Make a request to API using client_id and private_key
|
46
53
|
file = GroupDocs::Storage::File.upload!(filepath, {})
|
47
54
|
when 'url'
|
48
55
|
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
49
56
|
else
|
50
57
|
raise 'Wrong GUID source.'
|
51
58
|
end
|
52
|
-
|
53
|
-
#
|
59
|
+
|
60
|
+
#Copy file using request to API
|
54
61
|
unless settings.copy.nil?
|
55
62
|
file = file.copy!(settings.dest_path, {})
|
56
63
|
button = settings.copy
|
57
64
|
end
|
58
65
|
|
59
|
-
#
|
66
|
+
#Move file using request to API
|
60
67
|
unless settings.move.nil?
|
61
68
|
file = file.move!(settings.dest_path, {})
|
62
69
|
button = settings.move
|
63
70
|
end
|
64
71
|
|
65
|
-
#
|
72
|
+
#Result message
|
66
73
|
if file
|
67
74
|
massage = "File was #{button}'ed to the <font color=\"blue\">#{settings.dest_path}</font> folder"
|
68
75
|
end
|
@@ -71,6 +78,6 @@ post '/sample05' do
|
|
71
78
|
err = e.message
|
72
79
|
end
|
73
80
|
|
74
|
-
#
|
81
|
+
#Set variables for template
|
75
82
|
haml :sample05, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :destPath => settings.dest_path, :massage => massage, :err => err}
|
76
83
|
end
|
@@ -1,80 +1,86 @@
|
|
1
|
-
#
|
1
|
+
#GET request
|
2
2
|
get '/sample06' do
|
3
3
|
haml :sample06
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
#POST request
|
7
7
|
post '/sample06' do
|
8
|
-
#
|
8
|
+
#Set variables
|
9
9
|
set :client_id, params[:clientId]
|
10
10
|
set :private_key, params[:privateKey]
|
11
11
|
set :base_path, params[:basePath]
|
12
12
|
require 'net/http'
|
13
13
|
|
14
14
|
begin
|
15
|
-
#
|
15
|
+
#Check required variables
|
16
16
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
17
17
|
|
18
|
-
|
18
|
+
#Prepare base path
|
19
|
+
if settings.base_path.empty?
|
20
|
+
base_path = 'https://api.groupdocs.com'
|
21
|
+
elsif settings.base_path.match('/v2.0')
|
22
|
+
base_path = settings.base_path.split('/v2.0')[0]
|
23
|
+
else
|
24
|
+
base_path = settings.base_path
|
25
|
+
end
|
19
26
|
|
20
|
-
#
|
27
|
+
#Configure your access to API server
|
21
28
|
GroupDocs.configure do |groupdocs|
|
22
29
|
groupdocs.client_id = settings.client_id
|
23
30
|
groupdocs.private_key = settings.private_key
|
24
|
-
#
|
25
|
-
groupdocs.api_server =
|
31
|
+
#Optionally specify API server and version
|
32
|
+
groupdocs.api_server = base_path # default is 'https://api.groupdocs.com'
|
26
33
|
end
|
27
34
|
|
28
35
|
|
29
|
-
#
|
36
|
+
#Construct file path and open file
|
30
37
|
file_one_path = "#{File.dirname(__FILE__)}/#{params[:fiDocument][:filename]}"
|
31
38
|
File.open(file_one_path, 'wb') { |f| f.write(params[:fiDocument][:tempfile].read) }
|
32
39
|
|
33
40
|
|
34
|
-
#
|
41
|
+
#Create new file
|
35
42
|
file_one = GroupDocs::Storage::File.new(name: params[:fiDocument][:filename], local_path: file_one_path)
|
36
43
|
document_one = file_one.to_document
|
37
44
|
|
38
|
-
#
|
45
|
+
#Construct signature path and open file
|
39
46
|
signature_one_path = "#{Dir.tmpdir}/#{params[:fiSignature][:filename]}"
|
40
47
|
File.open(signature_one_path, 'wb') { |f| f.write(params[:fiSignature][:tempfile].read) }
|
41
48
|
|
42
|
-
#
|
49
|
+
#Add signature to file using API
|
43
50
|
signature_one = GroupDocs::Signature.new(name: params[:fiSignature][:filename], image_path: signature_one_path)
|
44
51
|
signature_one.position = {top: 0.83319, left: 0.72171, width: 100, height: 40}
|
45
52
|
|
46
|
-
|
47
|
-
# Make a request to API using client_id and private_key
|
53
|
+
#Make a request to API using client_id and private_key
|
48
54
|
signed_documents = GroupDocs::Document.sign_documents!([document_one], [signature_one], {})
|
49
55
|
sleep(5)
|
50
56
|
|
51
|
-
#
|
57
|
+
#Get the document guid
|
52
58
|
document = GroupDocs::Signature.sign_document_status!(signed_documents)
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
to
|
60
|
+
#Prepare to sign url
|
61
|
+
iframe = "/document-viewer/embed/#{document.guid}"
|
62
|
+
# Construct result string
|
63
|
+
url = GroupDocs::Api::Request.new(:path => iframe).prepare_and_sign_url
|
64
|
+
#Generate iframe URL
|
65
|
+
case base_path
|
66
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
67
|
+
iframe = "https://stage-api-groupdocs.dynabic.com#{url}"
|
68
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
69
|
+
iframe = "https://dev-apps.groupdocs.com#{url}"
|
70
|
+
else
|
71
|
+
iframe = "https://apps.groupdocs.com#{url}"
|
64
72
|
end
|
65
73
|
|
66
|
-
#
|
67
|
-
iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
68
|
-
|
69
|
-
# Generate result
|
74
|
+
#Generate result
|
70
75
|
if signed_documents
|
71
|
-
|
76
|
+
#Make iframe
|
77
|
+
iframe = "<iframe id='downloadframe' src='#{iframe}' width='800' height='1000'></iframe>"
|
72
78
|
end
|
73
79
|
|
74
80
|
rescue Exception => e
|
75
81
|
err = e.message
|
76
82
|
end
|
77
83
|
|
78
|
-
#
|
84
|
+
#Set variables for template
|
79
85
|
haml :sample06, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :err => err}
|
80
86
|
end
|