s3_proxy 0.0.1 → 0.1.0
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/lib/s3_proxy/app.rb +8 -9
- data/lib/s3_proxy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dea44cf361b902f466809821fe30b411db50add3
|
4
|
+
data.tar.gz: 8d929051a8382e50fad93796c980613c9e140f1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb0718bf8606acda33658d475862aff4482bdf59afb2fffb08a86da53ae421a266054de9c32e38c9d09c8bd71608c87294e08703e6df0c5d53e9e1372c94ce31
|
7
|
+
data.tar.gz: 4cb738cac629cd46beec034f40286790f4c5cb738a6519f10586f50daba3d86f5e8d2667d474739fb93df127dd2ae885f061ec34f3e23b9b21630e5c6733b252
|
data/lib/s3_proxy/app.rb
CHANGED
@@ -12,14 +12,15 @@ module S3Proxy
|
|
12
12
|
return Errors.not_found if env['PATH_INFO'].empty?
|
13
13
|
|
14
14
|
_, bucket, key = env['PATH_INFO'].split('/', 3)
|
15
|
+
path = {bucket: bucket, key: key}
|
15
16
|
|
16
|
-
head = s3.head_object(
|
17
|
+
head = s3.head_object(path)
|
17
18
|
return Errors.not_found unless head
|
18
19
|
|
19
20
|
if env['rack.hijack?']
|
20
|
-
hijack env
|
21
|
+
hijack env, path, head
|
21
22
|
else
|
22
|
-
gentle env
|
23
|
+
gentle env, path, head
|
23
24
|
end
|
24
25
|
|
25
26
|
rescue Aws::S3::Errors::NoSuchKey
|
@@ -28,7 +29,7 @@ module S3Proxy
|
|
28
29
|
|
29
30
|
private
|
30
31
|
|
31
|
-
def hijack(env)
|
32
|
+
def hijack(env, path, head)
|
32
33
|
env['rack.hijack'].call
|
33
34
|
|
34
35
|
io = env['rack.hijack_io']
|
@@ -41,18 +42,16 @@ module S3Proxy
|
|
41
42
|
io.write "\r\n"
|
42
43
|
io.flush
|
43
44
|
|
44
|
-
s3.get_object(
|
45
|
+
s3.get_object(path, target: io)
|
45
46
|
ensure
|
46
47
|
io.close
|
47
48
|
end
|
48
49
|
return [200, {}, ['']]
|
49
50
|
end
|
50
51
|
|
51
|
-
def gentle(env)
|
52
|
-
sio = StringIO.new('','w+')
|
53
|
-
|
52
|
+
def gentle(env, path, head)
|
54
53
|
fiber = Fiber.new do
|
55
|
-
s3.get_object(
|
54
|
+
s3.get_object(path) do |chunk|
|
56
55
|
Fiber.yield(chunk)
|
57
56
|
end
|
58
57
|
Fiber.yield(nil)
|
data/lib/s3_proxy/version.rb
CHANGED