@@ -13,7 +13,7 @@ A Ruby server for the [tus resumable upload protocol]. It implements the core
13
13
14
14
``` rb
15
15
# Gemfile
16
- gem " tus-server" , " ~> 2.0 "
16
+ gem " tus-server" , " ~> 2.3 "
17
17
```
18
18
19
19
## Usage
@@ -28,44 +28,41 @@ Rails.application.routes.draw do
28
28
end
29
29
```
30
30
31
- Otherwise you can run it in ` config.ru ` :
32
-
33
- ``` rb
34
- # config.ru (Rack)
35
- require " tus/server"
36
-
37
- map " /files" do
38
- run Tus ::Server
39
- end
40
- ```
41
-
42
31
Now you can tell your tus client library (e.g. [ tus-js-client] ) to use this
43
32
endpoint:
44
33
45
34
``` js
46
35
// using tus-js-client
47
36
new tus.Upload (file, {
48
- endpoint: " /files" ,
49
- chunkSize: 5 * 1024 * 1024 , // required unless using Falcon
37
+ endpoint: ' /files' ,
38
+ chunkSize: 5 * 1024 * 1024 , // chunking is required unless you're using Falcon
50
39
// ...
51
40
})
41
+
42
+ // OR
43
+
44
+ // using Uppy
45
+ uppy .use (Uppy .Tus , {
46
+ endpoint: ' /files' ,
47
+ chunkSize: 5 * 1024 * 1024 , // chunking is required unless you're using Falcon
48
+ })
52
49
```
53
50
54
51
By default uploaded files will be stored in the ` data/ ` directory. After the
55
52
upload is complete, you'll probably want to attach the uploaded file to a
56
- database record. [ Shrine] is currently the only file attachment library that
57
- provides an integration with tus-ruby-server, see [ this walkthrough] [ shrine
58
- resumable walkthrough] that adds resumable uploads from scratch, and for a
59
- complete example you can check out the [ demo app] [ shrine-tus-demo ] .
53
+ database record. [ Shrine] is a file attachment library that provides
54
+ integration with tus-ruby-server, see [ this walkthrough] [ shrine resumable
55
+ walkthrough] that adds resumable uploads from scratch, and for a complete
56
+ example you can check out the [ demo app] [ shrine-tus-demo ] .
60
57
61
58
### Streaming web server
62
59
63
60
Running the tus server alongside your main app using popular web servers like
64
- Puma or Unicorn is probably fine for most cases, however, it does come with a
65
- few gotchas. First, since these web servers don't accept partial requests
66
- (request where the request body hasn't been fully received), the tus client
67
- must be configured to split the upload into multiple requests. Second, since
68
- web workers are tied for the duration of the request, serving uploaded files
61
+ Puma or Unicorn is probably fine for most cases, but it does come with a few
62
+ gotchas. First, since these web servers don't accept partial requests (request
63
+ where the request body hasn't been fully received), the tus client must be
64
+ configured to split the upload into multiple requests. Second, since web
65
+ workers are tied for the duration of the request, serving uploaded files
69
66
through the tus server app could significantly impact request throughput; this
70
67
can be avoided by having your frontend server (Nginx) serve the files if using
71
68
` Filesystem ` storage, or if you're using a cloud service like S3 having
0 commit comments