rack-grid-serve 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack/grid_serve.rb +11 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9582271b0b27969b2af85d1048a1e5b47a6f1819
4
- data.tar.gz: 8b51095b5440fe2cd4e18ef714a9e1016b3e5ef0
3
+ metadata.gz: 2a11280dd4dffb5008753a183fcbf54d09947460
4
+ data.tar.gz: cdfa9132a8459c8ba7b749c6ce713b4580c91b12
5
5
  SHA512:
6
- metadata.gz: 5fcea0b1ab25709516cce85984a4c9d05608c198de5235f8957436b7b7755436fa05e0342909ba2ef03e595249700f7e76ef54dcd1e7a4308b59c073d60404a6
7
- data.tar.gz: b49ffaac118d2fe4ed6f82c477b4e5bc6b52836d33d88fb57f85fc1a6115c9cab515d41e1c2a04ace3f4af488fb37da84ba1e4feade96704895623919db8d900
6
+ metadata.gz: be437c29d9d41ca89318e79bf195a77a6e3537539e5402be88b73683ae68bf233b8e497d54d8fb01a698879f556572fa939f15026dcc9a43fced98ee00518798
7
+ data.tar.gz: defa40e7cfc0cdc101b70de3a6b8b4afa9883d9f0882703bec04c275bb02df693c2086f4ad01d3fc223b732fec6280dc0d700388d2df1c6cf797b2525003fa90
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  class Rack::GridServe
10
10
 
11
- VERSION = '0.0.5'
11
+ VERSION = '0.0.6'
12
12
 
13
13
  def initialize app, opts={}
14
14
  @app = app
@@ -28,15 +28,19 @@ class Rack::GridServe
28
28
  if file.nil?
29
29
  [404, {'Content-Type'=>'text/plain'}, 'Not Found']
30
30
  else
31
- last_modified = Time.at file.info.upload_date.to_i
31
+ last_modified = Time.at file['uploadDate'].to_i
32
32
  headers = {
33
- 'Content-Type' => file.info.content_type,
34
- 'ETag' => file.info.md5,
33
+ 'Content-Type' => file['contentType'],
34
+ 'ETag' => file['md5'],
35
35
  'Last-Modified' => last_modified.httpdate,
36
36
  'Cache-Control' => @cache_control
37
37
  }
38
38
  Rack::ConditionalGet.new(lambda {|cg_env|
39
- [200, headers, [file.data]]
39
+ content = String.new
40
+ @db.fs.open_download_stream(file['_id']) do |stream|
41
+ content = stream.read
42
+ end
43
+ [200, headers, [content]]
40
44
  }).call(env)
41
45
  end
42
46
  else
@@ -61,12 +65,12 @@ class Rack::GridServe
61
65
 
62
66
  def find_file req
63
67
  str = id_or_filename req
64
- @db.fs.find_one({
68
+ @db.fs.find({
65
69
  '$or' => [
66
70
  {_id: str},
67
71
  {filename: str}
68
72
  ]
69
- })
73
+ }).first
70
74
  end
71
75
 
72
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-grid-serve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Riga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-04 00:00:00.000000000 Z
11
+ date: 2017-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack