tus-server 2.1.0 → 2.1.1
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/CHANGELOG.md +4 -0
- data/README.md +14 -10
- data/lib/tus/server.rb +16 -11
- data/tus-server.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69d128e57072bd02cb340fa74fadce8b325a8163bfae16d96acfa17770ae2bd1
|
4
|
+
data.tar.gz: 46fd5fba0d0fde85385564ad46aa1ad71ed16dcb84022d7947a7970ac1bf40e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02df94c40fe475de5c3b9e23e0089a827aed7f8970a6c248abe8e64106b5d4babb5f957bfadfe7571e16eaf41ba50f0d5c3d9cfcdf63e8567cf0e9e79318ffec
|
7
|
+
data.tar.gz: 47d2d27bbb014e489d6393af0d5e03c2583f78cb4d913c0d19a664150754f7de4d77bf21313c24072538b11735ad10a98c45ec8daa6f84324a0dad331aa0dfc8
|
data/CHANGELOG.md
CHANGED
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
|
58
|
-
with tus-ruby-server, see [shrine
|
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[:
|
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[:
|
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 `:
|
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[:
|
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
|
data/lib/tus/server.rb
CHANGED
@@ -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]
|
27
|
-
opts[:expiration_time]
|
28
|
-
opts[:disposition]
|
29
|
-
opts[:
|
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
|
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
|
-
&
|
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
|
386
|
-
|
387
|
-
|
388
|
-
|
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
|
data/tus-server.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2018-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roda
|