s3_proxy 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec212812eb12625e1b6513fab200d497bfd8ea30
4
- data.tar.gz: c7542c717e24e2d9cf12bf2e67222cd733c90911
3
+ metadata.gz: dea44cf361b902f466809821fe30b411db50add3
4
+ data.tar.gz: 8d929051a8382e50fad93796c980613c9e140f1d
5
5
  SHA512:
6
- metadata.gz: b26d2daa7e6e5e20ece00f10fab03412aa0b09cf2121644bc6e47dcfa5845411d2fa0c8f6d63745fe5ae11f4bb760d09b7f772e035b50868fa37c195a854f90d
7
- data.tar.gz: b9c789c1e55139bd8b6769a7dac5a02a3a168a62bc7104b23564e64953f36036c3189e558abb188b8b88faf0c83c204f91c40ddf932a23cf899fefe53b7e3e1c
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(bucket: bucket, key: key)
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({bucket: bucket, key: key}, target: io)
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(bucket: bucket, key: key) do |chunk|
54
+ s3.get_object(path) do |chunk|
56
55
  Fiber.yield(chunk)
57
56
  end
58
57
  Fiber.yield(nil)
@@ -1,3 +1,3 @@
1
1
  module S3Proxy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)