rbbt-rest 1.2.8 → 1.2.9
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 +8 -8
- data/lib/rbbt/rest/file_server.rb +23 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWFhMmFjMWFjYzU4Njg2ODYyYWRkY2NkMjNmYWFiMGQ3NmZkYjBkZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2RhYmYyYmI2Njg5YTE3YTZhYzkyNDg1OWMzNzc2NzgyYzVjZmQ4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDk0MDczNTUxNGNhMTY2NzM3YjBmNDc3YjYzNGFiODZhYWI4MjdjMzVkZDQ0
|
10
|
+
NDIzYzA4YWJhMDAwNjU0ZWEzZGU5MTI4MmE0MWViOGNkOWJlNGMwM2JjYWRi
|
11
|
+
YmJlNTQ2ZGMwZjA1ODg5M2U2ZmY1MTljMGU1ZWFjMGE0NjJmMzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWExOWJmODJiMDNkZmNlNjAyOTcxZGQxYjAxYjQ4OWIzMTk1YjAzMTNiYzhi
|
14
|
+
NjNhZDhiMTlmNTFmYzFmYzcwMjI1ZmEzZWIyNzdmMjUxODNhMzFmNmZhYjM3
|
15
|
+
MDgxOTE3ODQwYWNjMWE2M2YzMDA4NjJlNzE5MTUwZjNhZGY0YmQ=
|
@@ -16,6 +16,8 @@ module Sinatra
|
|
16
16
|
|
17
17
|
resource = Kernel.const_get(resource)
|
18
18
|
|
19
|
+
directory = $1 if resource.subdir and directory =~ /^#{resource.subdir}\/?(.*)/
|
20
|
+
|
19
21
|
path = resource.root[directory]
|
20
22
|
|
21
23
|
raise "For security reasons the file path must not leave the resource root directory" unless Misc.path_relative_to(resource.root, path)
|
@@ -25,15 +27,24 @@ module Sinatra
|
|
25
27
|
raise "Directory does not exist" unless path.exists? or create
|
26
28
|
raise "Directory does not exist and can not create it" unless path.exists? or path.produce.exists?
|
27
29
|
|
28
|
-
stream
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
#stream do |out|
|
31
|
+
# io = nil
|
32
|
+
# Misc.in_dir path.find do
|
33
|
+
# io = CMD.cmd("tar cfvz - '.'", :pipe => true)
|
34
|
+
# end
|
35
|
+
# while not io.closed? and block = io.read(4096)
|
36
|
+
# out << block
|
37
|
+
# end
|
38
|
+
# io.close
|
39
|
+
# out.flush
|
40
|
+
#end
|
41
|
+
|
42
|
+
TmpFile.with_file :extension => 'tar.gz' do |file|
|
43
|
+
Misc.in_dir path.find do
|
44
|
+
CMD.cmd("tar cfvz '#{file}' .")
|
36
45
|
end
|
46
|
+
headers['Content-Encoding'] = 'gzip'
|
47
|
+
send_file file, :filename => directory.gsub('/','_') + '.tar.gz', :type => "application/x-gzip"
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
@@ -54,8 +65,10 @@ module Sinatra
|
|
54
65
|
|
55
66
|
Log.debug("Resource: #{[resource, file, path, path.find] * " | "}")
|
56
67
|
|
57
|
-
raise "File does not exist" unless path.exists?
|
58
|
-
|
68
|
+
raise "File does not exist and can not create it" unless path.exists?
|
69
|
+
|
70
|
+
directory_url = File.join("/resource", resource.to_s , 'get_directory') << '?' << "create=#{create}" << '&' << "directory=#{file}"
|
71
|
+
redirect to(directory_url) if path.directory?
|
59
72
|
|
60
73
|
send_file path.find, :filename => path
|
61
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|