tus-server 2.1.0 → 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: 16cf0c007be7d383ca0bf2d4aefa6d6c477ac7d32b1905a8ad6c0413da233e57
4
- data.tar.gz: 258d7d591fc1416468ea21ea42d29ed53f2a64eeade9e5293bdbecc3e5f6a599
3
+ metadata.gz: 69d128e57072bd02cb340fa74fadce8b325a8163bfae16d96acfa17770ae2bd1
4
+ data.tar.gz: 46fd5fba0d0fde85385564ad46aa1ad71ed16dcb84022d7947a7970ac1bf40e0
5
5
  SHA512:
6
- metadata.gz: d642a6f120fd220af27bfc7cf8904459acafa6191934a4922913b10b296e0308cd3093223b39317ffb901318e83da2bcd3fa056cf7d2a36a2f7131ce18b8d8ca
7
- data.tar.gz: c0bf56b77ee95fa1aab167f29fd38feabb1919f7e7d85b1c7705c5adbcba97f9612b5633880af9b603b433a3778518b7875bd5bfafff4f446c476d621c0b9c99
6
+ metadata.gz: 02df94c40fe475de5c3b9e23e0089a827aed7f8970a6c248abe8e64106b5d4babb5f957bfadfe7571e16eaf41ba50f0d5c3d9cfcdf63e8567cf0e9e79318ffec
7
+ data.tar.gz: 47d2d27bbb014e489d6393af0d5e03c2583f78cb4d913c0d19a664150754f7de4d77bf21313c24072538b11735ad10a98c45ec8daa6f84324a0dad331aa0dfc8
@@ -1,3 +1,7 @@
1
+ ## 2.1.1 (2018-15-26)
2
+
3
+ * Rename `:download_url` option to `:redirect_download` (@janko-m)
4
+
1
5
  ## 2.1.0 (2018-05-15)
2
6
 
3
7
  * Add `:download_url` server option for redirecting to a download URL (@janko-m)
data/README.md CHANGED
@@ -24,7 +24,6 @@ main application. If you're using Rails, you can mount it in `config/routes.rb`:
24
24
  ```rb
25
25
  # config/routes.rb (Rails)
26
26
  Rails.application.routes.draw do
27
- # ...
28
27
  mount Tus::Server => "/files"
29
28
  end
30
29
  ```
@@ -54,8 +53,10 @@ new tus.Upload(file, {
54
53
 
55
54
  By default uploaded files will be stored in the `data/` directory. After the
56
55
  upload is complete, you'll probably want to attach the uploaded file to a
57
- database record. [Shrine] is one file attachment library that integrates nicely
58
- with tus-ruby-server, see [shrine-tus-demo] for an example integration.
56
+ database record. [Shrine] is currently the only file attachment library that
57
+ integrates well with tus-ruby-server, see [this walkthrough][shrine resumable
58
+ walkthrough] that adds resumable uploads from scratch, and for a complete
59
+ example you can check out the [demo app][shrine-tus-demo].
59
60
 
60
61
  ### Goliath
61
62
 
@@ -174,9 +175,9 @@ If you're using Rails, you can enable the `Rack::Sendfile` middleware by
174
175
  setting the `config.action_dispatch.x_sendfile_header` value accordingly:
175
176
 
176
177
  ```rb
177
- config.action_dispatch.x_sendfile_header = "X-Sendfile" # Apache and lighttpd
178
+ Rails.application.config.action_dispatch.x_sendfile_header = "X-Sendfile" # Apache and lighttpd
178
179
  # or
179
- config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # Nginx
180
+ Rails.application.config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # Nginx
180
181
  ```
181
182
 
182
183
  Otherwise you can add the `Rack::Sendfile` middleware to the stack in
@@ -216,22 +217,22 @@ last to be **5MB or larger**, so that is the minimum chunk size that you can
216
217
  specify on your tus client if you want to use the S3 storage.
217
218
 
218
219
  If you'll be retrieving uploaded files through the tus server app, it's
219
- recommended to set `Tus::Server.opts[:download_url]` to `true`. This will avoid
220
- tus server downloading and serving the file from S3, and instead have the
220
+ recommended to set `Tus::Server.opts[:redirect_download]` to `true`. This will
221
+ avoid tus server downloading and serving the file from S3, and instead have the
221
222
  download endpoint redirect to the direct S3 object URL.
222
223
 
223
224
  ```rb
224
- Tus::Server.opts[:download_url] = true
225
+ Tus::Server.opts[:redirect_download] = true
225
226
  ```
226
227
 
227
228
  You can customize how the S3 object URL is being generated by passing a block
228
- to `:download_url`, which will then be evaluated in the context of the
229
+ to `:redirect_download`, which will then be evaluated in the context of the
229
230
  `Tus::Server` instance (which allows accessing the `request` object). See
230
231
  [`Aws::S3::Object#get`] for the list of options that
231
232
  `Tus::Storage::S3#file_url` accepts.
232
233
 
233
234
  ```rb
234
- Tus::Server.opts[:download_url] = -> (uid, info, **options) do
235
+ Tus::Server.opts[:redirect_download] = -> (uid, info, **options) do
235
236
  storage.file_url(uid, info, response_expires: 10, **options) # link expires after 10 seconds
236
237
  end
237
238
  ```
@@ -386,6 +387,8 @@ $ bundle exec rake test # unit tests
386
387
  $ bundle exec cucumber # acceptance tests
387
388
  ```
388
389
 
390
+ Set `MONGO=1` environment variable if you want to also run MongoDB tests.
391
+
389
392
  ## Inspiration
390
393
 
391
394
  The tus-ruby-server was inspired by [rubytus].
@@ -416,3 +419,4 @@ The tus-ruby-server was inspired by [rubytus].
416
419
  [goliath-rack_proxy]: https://github.com/janko-m/goliath-rack_proxy
417
420
  [Rack::Sendfile]: https://www.rubydoc.info/github/rack/rack/master/Rack/Sendfile
418
421
  [`Aws::S3::Object#get`]: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#get-instance_method
422
+ [shrine resumable walkthrough]: https://github.com/shrinerb/shrine/wiki/Adding-Resumable-Uploads
@@ -23,10 +23,10 @@ module Tus
23
23
  SUPPORTED_CHECKSUM_ALGORITHMS = %w[sha1 sha256 sha384 sha512 md5 crc32]
24
24
  RESUMABLE_CONTENT_TYPE = "application/offset+octet-stream"
25
25
 
26
- opts[:max_size] = nil
27
- opts[:expiration_time] = 7*24*60*60
28
- opts[:disposition] = "inline"
29
- opts[:download_url] = nil
26
+ opts[:max_size] = nil
27
+ opts[:expiration_time] = 7*24*60*60
28
+ opts[:disposition] = "inline"
29
+ opts[:redirect_download] = nil
30
30
 
31
31
  plugin :all_verbs
32
32
  plugin :default_headers, {"Content-Type" => ""}
@@ -168,11 +168,11 @@ module Tus
168
168
  content_disposition += "; filename=\"#{name}\"" if name
169
169
  content_type = type || "application/octet-stream"
170
170
 
171
- if download_url
171
+ if redirect_download
172
172
  redirect_url = instance_exec(uid, info.to_h,
173
173
  content_type: content_type,
174
174
  content_disposition: content_disposition,
175
- &download_url)
175
+ &redirect_download)
176
176
 
177
177
  r.redirect redirect_url
178
178
  else
@@ -382,12 +382,17 @@ module Tus
382
382
  request.halt
383
383
  end
384
384
 
385
- def download_url
386
- if opts[:download_url] == true
387
- storage.method(:file_url)
388
- else
389
- opts[:download_url]
385
+ def redirect_download
386
+ value = opts[:redirect_download]
387
+
388
+ if opts[:download_url]
389
+ value ||= opts[:download_url]
390
+ warn "[TUS-RUBY-SERVER DEPRECATION] The :download_url option has been renamed to :redirect_download."
390
391
  end
392
+
393
+ value = storage.method(:file_url) if value == true
394
+
395
+ value
391
396
  end
392
397
 
393
398
  def storage
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "tus-server"
3
- gem.version = "2.1.0"
3
+ gem.version = "2.1.1"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.2"
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tus-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
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: 2018-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda