shrine-tus 1.2.1 → 2.1.1

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
  SHA256:
3
- metadata.gz: b464e4d6d99f84092e1343586bc0102882ada25831fdb9eb8085fe820f823e19
4
- data.tar.gz: b1972b8c02e3c9c38a24f0cc4b214fae775d08a20607d2f39c002c7da79c0baf
3
+ metadata.gz: c8aef0acf353a78d6957ff427b68ad717a1af9ad64f2592fe85c4566ca980b84
4
+ data.tar.gz: 0b300ece5f083fbc078034309aa53cdc652aeaad68eaa495479d3c2ee046518d
5
5
  SHA512:
6
- metadata.gz: 72106677f12aab0d05cbc85918af78fa31467ac08c3dbf2f3ed3528de39282f22be601d9e885a11ad131e388e3d1435ca4fb8e150edee128bde46770b2709253
7
- data.tar.gz: 73a95ada3fee3d760702beed96b91fde1f7fc18f0be38b6f44af64365ce339a4d194e87b323df1d839828a8ff0ba9e689516ae134f55cd9171d8d3c6a45154d6
6
+ metadata.gz: aa9848d522da77ebd06ae9eeea0822bb2806da90ab632ab34baaea6e2a386076428a32bbe44e11422b9c9f55a2e41ea9c9a2aaccf922c4d570e73387e5b626d2
7
+ data.tar.gz: 4f1128b8f3007ea339f9148e3b618f179d79a42dacb40d47657db117794193dce63113d095329efb6fca0260b8878b5e1ee96df1c83c340c3d6cb7df71a4eb37
data/README.md CHANGED
@@ -5,7 +5,7 @@ Provides tools for integrating [Shrine] with [tus-ruby-server].
5
5
  ## Installation
6
6
 
7
7
  ```rb
8
- gem "shrine-tus", "~> 1.2"
8
+ gem "shrine-tus", "~> 2.0"
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -37,6 +37,11 @@ Movie.create(video: file_data)
37
37
 
38
38
  See [shrine-tus-demo] for an example application that uses shrine-tus.
39
39
 
40
+ Note that by default **Shrine won't extract metadata from directly upload
41
+ files**, instead it will just copy metadata that was extracted on the client
42
+ side. See [this section][metadata direct uploads] for the rationale and
43
+ instructions on how to opt in.
44
+
40
45
  ### Approach A: Downloading through tus server
41
46
 
42
47
  Conceptionally the simplest setup is to have Shrine download the uploaded file
@@ -184,8 +189,9 @@ $ bundle exec rake test
184
189
  [MIT](/LICENSE.txt)
185
190
 
186
191
  [Shrine]: https://github.com/shrinerb/shrine
187
- [tus-ruby-server]: https://github.com/janko-m/tus-ruby-server
188
- [Down]: https://github.com/janko-m/down
192
+ [tus-ruby-server]: https://github.com/janko/tus-ruby-server
193
+ [Down]: https://github.com/janko/down
189
194
  [HTTP.rb]: https://github.com/httprb/http
190
195
  [shrine-tus-demo]: https://github.com/shrinerb/shrine-tus-demo
191
196
  [tusd]: https://github.com/tus/tusd
197
+ [metadata direct uploads]: https://github.com/shrinerb/shrine/blob/master/doc/metadata.md#direct-uploads
@@ -5,17 +5,19 @@ class Shrine
5
5
  module Plugins
6
6
  module Tus
7
7
  module AttacherMethods
8
- def assign(value)
9
- if value.is_a?(String) && value != ""
10
- data = JSON.parse(value)
11
- data["id"] = tus_url_to_storage_id(data["id"], cache.storage) if URI.regexp =~ data["id"]
12
- super(data.to_json)
13
- else
14
- super
8
+ private
9
+
10
+ def cached(data, **options)
11
+ data = data.dup
12
+ data = JSON.parse(data) if data.is_a?(String)
13
+
14
+ if URI.regexp =~ (data["id"] || data[:id])
15
+ id = data.delete("id") || data.delete(:id)
16
+ data["id"] = tus_url_to_storage_id(id, cache.storage)
15
17
  end
16
- end
17
18
 
18
- private
19
+ super(data, **options)
20
+ end
19
21
 
20
22
  def tus_url_to_storage_id(tus_url, storage)
21
23
  tus_uid = tus_url.split("/").last
@@ -10,49 +10,28 @@ class Shrine
10
10
  def initialize(tus_storage: nil, **options)
11
11
  @tus_storage = tus_storage
12
12
 
13
- super(**options)
14
- end
15
-
16
- def download(id, **options)
17
- if tus_storage
18
- download_from_tus_storage(tus_uid(id))
19
- else
20
- super
21
- end
13
+ super(delete: true, **options)
22
14
  end
23
15
 
24
16
  def open(id, **options)
25
- if tus_storage
26
- open_from_tus_storage(tus_uid(id))
27
- else
28
- super
29
- end
17
+ return super unless tus_storage
18
+
19
+ open_from_tus_storage(tus_uid(id), **options)
20
+ rescue ::Tus::NotFound
21
+ raise Shrine::FileNotFound, "file #{id.inspect} not found on storage"
30
22
  end
31
23
 
32
24
  private
33
25
 
34
- def download_from_tus_storage(uid)
35
- tempfile = Tempfile.new("shrine-tus", binmode: true)
36
-
37
- response = get_tus_file(uid)
38
- response.each do |chunk|
39
- tempfile << chunk
40
- chunk.clear # deallocate string
41
- end
42
- response.close
43
-
44
- tempfile.open
45
- tempfile
46
- end
47
-
48
- def open_from_tus_storage(uid)
49
- response = get_tus_file(uid)
26
+ def open_from_tus_storage(uid, rewindable: true, **)
50
27
  info = get_tus_info(uid)
28
+ response = get_tus_file(uid)
51
29
 
52
30
  Down::ChunkedIO.new(
53
- size: Integer(info["Upload-Length"]),
54
- chunks: response.each,
55
- on_close: response.method(:close),
31
+ size: Integer(info["Upload-Length"]),
32
+ chunks: response.each,
33
+ on_close: response.method(:close),
34
+ rewindable: rewindable,
56
35
  )
57
36
  end
58
37
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-tus"
3
- gem.version = "1.2.1"
3
+ gem.version = "2.1.1"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -13,13 +13,13 @@ Gem::Specification.new do |gem|
13
13
  gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
14
14
  gem.require_path = "lib"
15
15
 
16
- gem.add_dependency "shrine", "~> 2.0"
16
+ gem.add_dependency "shrine", "~> 3.2"
17
17
  gem.add_dependency "tus-server", "~> 2.0"
18
- gem.add_dependency "shrine-url", "~> 2.1"
18
+ gem.add_dependency "shrine-url", "~> 2.4"
19
19
 
20
20
  gem.add_development_dependency "rake"
21
21
  gem.add_development_dependency "minitest"
22
22
  gem.add_development_dependency "webmock"
23
- gem.add_development_dependency "shrine-gridfs"
24
- gem.add_development_dependency "aws-sdk-s3", "~> 1.2"
23
+ gem.add_development_dependency "shrine-gridfs", "~> 1.0"
24
+ gem.add_development_dependency "aws-sdk-s3", "~> 1.14"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-tus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-15 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tus-server
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.1'
47
+ version: '2.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.1'
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,30 +98,30 @@ dependencies:
98
98
  name: shrine-gridfs
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '1.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: aws-sdk-s3
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.2'
117
+ version: '1.14'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.2'
124
+ version: '1.14'
125
125
  description:
126
126
  email:
127
127
  - janko.marohnic@gmail.com
@@ -153,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.6
156
+ rubygems_version: 3.1.1
158
157
  signing_key:
159
158
  specification_version: 4
160
159
  summary: Provides storage and plugin for easier integration between Shrine and tus-ruby-server.