tus-server 2.1.1 → 2.1.2
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 +5 -1
- data/README.md +54 -1
- data/lib/tus/input.rb +6 -0
- data/lib/tus/server.rb +7 -1
- 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: c0caef3d7cfbadc9b74678f99e687c0fe51bfbbab77acece73e9e1332aaa8661
|
4
|
+
data.tar.gz: 8be7b8e4ef8c2c6a5bc58ca11417c88b743b54252da7a3481f3866a591ef5abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e6d0496407297529e55063bbb27036d08697a986291dd08299e8994bbbeb6329d15dac4fa6a1137364e126379ae2fcd8c23df5500e0cb8c5e60074265070ae
|
7
|
+
data.tar.gz: b3328632108adeaf10761b3df9ab6ad9e957fe48a4b4ab92cccfaa36221f0c99be142af08ced374cbf1ab460e0b6622f0d964be55636683438b9c473e3533263
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -258,6 +258,55 @@ can for example change the `:endpoint` to use S3's accelerate host:
|
|
258
258
|
Tus::Storage::S3.new(endpoint: "https://s3-accelerate.amazonaws.com", **options)
|
259
259
|
```
|
260
260
|
|
261
|
+
### Google Cloud Storage, Microsoft Azure Blob Storage
|
262
|
+
|
263
|
+
While tus-ruby-server doesn't currently ship with integrations for Google Cloud
|
264
|
+
Storage or Microsoft Azure Blob Storage, you can still use these services via
|
265
|
+
**[Minio]**.
|
266
|
+
|
267
|
+
Minio is an open source distributed object storage server that implements the
|
268
|
+
Amazon S3 API and provides gateways for [GCP][minio gcp] and [Azure][minio
|
269
|
+
azure]. This means it's possible to use the existing S3 tus-ruby-server
|
270
|
+
integration to point to the Minio server, which will then in turn forward those
|
271
|
+
calls to GCP or Azure.
|
272
|
+
|
273
|
+
Let's begin by installing Minio via Homebrew:
|
274
|
+
|
275
|
+
```sh
|
276
|
+
$ brew install minio/stable/minio
|
277
|
+
```
|
278
|
+
|
279
|
+
And starting the Minio server as a gateway to GCP or Azure:
|
280
|
+
|
281
|
+
```sh
|
282
|
+
# Google Cloud Storage
|
283
|
+
$ export GOOGLE_APPLICATION_CREDENTIALS=/path/credentials.json
|
284
|
+
$ export MINIO_ACCESS_KEY=minioaccesskey
|
285
|
+
$ export MINIO_SECRET_KEY=miniosecretkey
|
286
|
+
$ minio gateway gcs yourprojectid
|
287
|
+
```
|
288
|
+
```sh
|
289
|
+
# Microsoft Azure Blob Storage
|
290
|
+
$ export MINIO_ACCESS_KEY=azureaccountname
|
291
|
+
$ export MINIO_SECRET_KEY=azureaccountkey
|
292
|
+
$ minio gateway azure
|
293
|
+
```
|
294
|
+
|
295
|
+
Now follow the displayed link to open the Minio web UI and create a bucket in
|
296
|
+
which you want your files to be stored. Once you've done that, you can
|
297
|
+
initialize `Tus::Storage::S3` to point to your Minio server and bucket:
|
298
|
+
|
299
|
+
```rb
|
300
|
+
Tus::Storage::S3.new(
|
301
|
+
access_key_id: "<MINIO_ACCESS_KEY>", # "AccessKey" value
|
302
|
+
secret_access_key: "<MINIO_SECRET_KEY>", # "SecretKey" value
|
303
|
+
endpoint: "<MINIO_ENDPOINT>", # "Endpoint" value
|
304
|
+
bucket: "<MINIO_BUCKET>", # name of the bucket you created
|
305
|
+
region: "us-east-1",
|
306
|
+
force_path_style: true,
|
307
|
+
)
|
308
|
+
```
|
309
|
+
|
261
310
|
### MongoDB GridFS
|
262
311
|
|
263
312
|
MongoDB has a specification for storing and retrieving large files, called
|
@@ -391,7 +440,7 @@ Set `MONGO=1` environment variable if you want to also run MongoDB tests.
|
|
391
440
|
|
392
441
|
## Inspiration
|
393
442
|
|
394
|
-
The tus-ruby-server was inspired by [rubytus].
|
443
|
+
The tus-ruby-server was inspired by [rubytus] and [tusd].
|
395
444
|
|
396
445
|
## License
|
397
446
|
|
@@ -420,3 +469,7 @@ The tus-ruby-server was inspired by [rubytus].
|
|
420
469
|
[Rack::Sendfile]: https://www.rubydoc.info/github/rack/rack/master/Rack/Sendfile
|
421
470
|
[`Aws::S3::Object#get`]: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#get-instance_method
|
422
471
|
[shrine resumable walkthrough]: https://github.com/shrinerb/shrine/wiki/Adding-Resumable-Uploads
|
472
|
+
[Minio]: https://minio.io
|
473
|
+
[minio gcp]: https://minio.io/gcp.html
|
474
|
+
[minio azure]: https://minio.io/azure.html
|
475
|
+
[tusd]: https://github.com/tus/tusd
|
data/lib/tus/input.rb
CHANGED
@@ -35,6 +35,12 @@ module Tus
|
|
35
35
|
@pos = 0
|
36
36
|
end
|
37
37
|
|
38
|
+
def rewindable?
|
39
|
+
@input.is_a?(Tempfile) || # Puma, Thin
|
40
|
+
@input.is_a?(StringIO) || # WEBRick, Puma, Thin
|
41
|
+
@input.class.name.end_with?("TeeInput") # Unicorn, Passenger
|
42
|
+
end
|
43
|
+
|
38
44
|
def close
|
39
45
|
# Rack input shouldn't be closed, we just support the interface
|
40
46
|
end
|
data/lib/tus/server.rb
CHANGED
@@ -10,6 +10,8 @@ require "tus/errors"
|
|
10
10
|
require "securerandom"
|
11
11
|
require "time"
|
12
12
|
|
13
|
+
require "rack/rewindable_input"
|
14
|
+
|
13
15
|
module Tus
|
14
16
|
class Server < Roda
|
15
17
|
SUPPORTED_VERSIONS = ["1.0.0"]
|
@@ -135,9 +137,13 @@ module Tus
|
|
135
137
|
validate_content_type!
|
136
138
|
validate_upload_offset!(info)
|
137
139
|
validate_content_length!(request.content_length.to_i, info) if request.content_length
|
138
|
-
validate_upload_checksum!(input) if request.headers["Upload-Checksum"]
|
139
140
|
|
140
141
|
begin
|
142
|
+
if request.headers["Upload-Checksum"]
|
143
|
+
input = Rack::RewindableInput.new(input) unless input.rewindable?
|
144
|
+
validate_upload_checksum!(input)
|
145
|
+
end
|
146
|
+
|
141
147
|
bytes_uploaded = storage.patch_file(uid, input, info.to_h)
|
142
148
|
rescue Tus::MaxSizeExceeded
|
143
149
|
validate_content_length!(input.pos, info)
|
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.2
|
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-
|
11
|
+
date: 2018-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roda
|