safe-t-rest 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/safe-t-bin +76 -0
- data/safe-t-rest.gemspec +5 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e20d688d2f00aa0da8542721bcf48bea3569325
|
4
|
+
data.tar.gz: ce79343210ed7631483f3aa85ba9f52a1ba18ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc68e6161be3c07ba250db4ab098fe1582adb1acaebd545ba60de34de70b9822f7cbb0f2805fe0d2747b9f2aeb4ad9bf0b60187ba3f432e717e5f91f18935aae
|
7
|
+
data.tar.gz: 99ff0681e20047f58e2ce797c9958176f3f60da4dfe678676fea5bfd5941b4b852725706236cefd69c0c0523b83eb765a79e472076cc204d3fe83c3ce3f51ea4
|
data/README.md
CHANGED
data/bin/safe-t-bin
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'safe-t-rest'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'base64'
|
7
|
+
require 'colorize'
|
8
|
+
|
9
|
+
|
10
|
+
class ApiBin
|
11
|
+
|
12
|
+
def self.main_loop
|
13
|
+
|
14
|
+
puts "Safe-T API -- Using 'safe-t-rest' GEM".blue
|
15
|
+
client = SafeTRest.new
|
16
|
+
puts "Please enter servers url: ".bold
|
17
|
+
client.url = gets.chomp
|
18
|
+
puts "Please enter username: ".bold
|
19
|
+
client.username = gets.chomp
|
20
|
+
puts "Please enter password: ".bold
|
21
|
+
client.password = gets.chomp
|
22
|
+
puts "Please enter Role ID: ".bold
|
23
|
+
client.role_id = gets.chomp
|
24
|
+
puts "Please enter Extenstion ID: ".bold
|
25
|
+
client.extenstion_id = gets.chomp
|
26
|
+
|
27
|
+
puts "Configuration Loaded".green
|
28
|
+
loop do
|
29
|
+
|
30
|
+
puts '1. List Files'.bold
|
31
|
+
puts '2. Upload Files'.bold
|
32
|
+
puts '3. Download Files'.bold
|
33
|
+
|
34
|
+
answer = gets.chomp
|
35
|
+
case answer
|
36
|
+
when '1'
|
37
|
+
puts "Please enter the path on the server to list (empty for root folder): "
|
38
|
+
path = gets.chomp
|
39
|
+
puts Nokogiri::XML(client.iGetFolderList(path))
|
40
|
+
when '2'
|
41
|
+
puts "Please enter the path to the file you want to upload: "
|
42
|
+
file = gets.chomp
|
43
|
+
filename = File.basename(file)
|
44
|
+
filepath = file.split('/')[-1]
|
45
|
+
upload_string = Base64.encode64(File.read(file))
|
46
|
+
args = {
|
47
|
+
:file_base64 => upload_string, # the file as a base64 string Base64.encode64(File.read(file))
|
48
|
+
:file_name => filename, # the name of the file
|
49
|
+
:folder_path => '', # empty means root folder
|
50
|
+
:root_folder_id => 417 # My Storage ID
|
51
|
+
}
|
52
|
+
answer = client.iFileUpload(args)
|
53
|
+
if answer == 'OK'
|
54
|
+
puts "File Uploaded".green
|
55
|
+
else
|
56
|
+
puts "Error Uploading File: #{answer}".red
|
57
|
+
end
|
58
|
+
when '3'
|
59
|
+
puts "Please enter the name of the file you want to download: "
|
60
|
+
filename = gets.chomp
|
61
|
+
puts "Please enter the path to the directory the file is in (empty for root directory): "
|
62
|
+
server_path = gets.chomp
|
63
|
+
puts "Please enter the path to save it to (example: /tmp): "
|
64
|
+
path = gets.chomp
|
65
|
+
args = {
|
66
|
+
:file_name => filename, # The name of the file to download
|
67
|
+
:folder_path => server_path, # The path of the file
|
68
|
+
:root_folder_id => 417 # My Storage ID
|
69
|
+
}
|
70
|
+
download_string = Base64.decode64(client.iFileDownload(args))
|
71
|
+
File.write("#{path}/#{filename}", download_string)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
ApiBin.main_loop
|
data/safe-t-rest.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'safe-t-rest'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.8'
|
4
4
|
s.date = Time.now.strftime('%Y-%m-%d')
|
5
5
|
s.summary = 'A ruby gem to interact with Safe-T Box.'
|
6
6
|
s.description = 'Ruby gem to interact with Safe-T Box rest API. '
|
@@ -11,10 +11,12 @@ Gem::Specification.new do |s|
|
|
11
11
|
|
12
12
|
s.files = Dir[
|
13
13
|
'README.md',
|
14
|
-
'
|
14
|
+
'bin/*.rb',
|
15
15
|
'lib/*.rb',
|
16
16
|
'*.gemspec'
|
17
17
|
]
|
18
|
-
|
18
|
+
s.bindir = 'bin'
|
19
|
+
s.executables << 'safe-t-bin'
|
20
|
+
s.default_executable = 'safe-t-bin'
|
19
21
|
s.add_dependency 'rest-client', '~> 1.7', '>= 1.7.3'
|
20
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe-t-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bar Hofesh
|
@@ -33,11 +33,13 @@ dependencies:
|
|
33
33
|
description: 'Ruby gem to interact with Safe-T Box rest API. '
|
34
34
|
email:
|
35
35
|
- Bar.Hofesh@safe-t.com
|
36
|
-
executables:
|
36
|
+
executables:
|
37
|
+
- safe-t-bin
|
37
38
|
extensions: []
|
38
39
|
extra_rdoc_files: []
|
39
40
|
files:
|
40
41
|
- README.md
|
42
|
+
- bin/safe-t-bin
|
41
43
|
- lib/safe-t-rest.rb
|
42
44
|
- safe-t-rest.gemspec
|
43
45
|
homepage: https://github.com/bararchy/safe-t-rest
|