tus-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/tus/client.rb +17 -3
- data/lib/tus/client/version.rb +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: 24530f6bf4e29af12bb753db0bd417553ae357bb80956aac1bf008df9835f276
|
4
|
+
data.tar.gz: cb0db63ef4be6893e97347e5d498360c4566c601f2a8ebdb4b6a63f2b889964a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8053eb9c45d03a14684618bc1e45e259414b232b5b3aebec5d9e64959d4cc20b2343df293d8094171832a79cc23e3e73e29ee3effc16cab26af6f53a5e4a6f5c
|
7
|
+
data.tar.gz: a4f386ec4a1401f209e1a87f166158d46929e935b09fb05b337ee1a97069255c3593325a1a0e6fbf5759a622031996030f04c4e5e33d50b149b5a7a676884974
|
data/README.md
CHANGED
@@ -6,9 +6,15 @@ TODO: Write the additional info
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
From the command line:
|
10
|
+
```bash
|
11
|
+
gem install tus-client
|
12
|
+
```
|
10
13
|
|
11
|
-
|
14
|
+
Or add this line to your `Gemfile`:
|
15
|
+
```rb
|
16
|
+
gem "tus-client"
|
17
|
+
```
|
12
18
|
|
13
19
|
## Usage
|
14
20
|
|
@@ -16,7 +22,7 @@ TODO: Write usage instructions here
|
|
16
22
|
|
17
23
|
## Development
|
18
24
|
|
19
|
-
|
25
|
+
Just clone the repo and open a pull request when done implementing your feature
|
20
26
|
|
21
27
|
## Contributing
|
22
28
|
|
data/lib/tus/client.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'net/http'
|
4
4
|
require 'base64'
|
5
5
|
|
6
|
-
|
6
|
+
require_relative 'client/version'
|
7
7
|
|
8
8
|
module Tus
|
9
9
|
class Client
|
@@ -24,14 +24,28 @@ module Tus
|
|
24
24
|
def upload(file_path)
|
25
25
|
raise 'No such file!' unless File.file?(file_path)
|
26
26
|
|
27
|
+
file_name = File.basename(file_path)
|
28
|
+
file_size = File.size(file_path)
|
27
29
|
io = File.open(file_path, 'rb')
|
28
30
|
|
29
|
-
|
31
|
+
upload_by_io(file_name: file_name, file_size: file_size, io: io)
|
32
|
+
end
|
33
|
+
|
34
|
+
def upload_by_io(file_name:, file_size:, io:)
|
35
|
+
raise 'Cannot upload a stream of unknown size!' unless file_size
|
36
|
+
|
37
|
+
uri = create_remote(file_name, file_size)
|
30
38
|
# we use only parameters that are known to the server
|
31
39
|
offset, length = upload_parameters(uri)
|
32
40
|
|
33
41
|
chunks = Enumerator.new do |yielder|
|
34
|
-
|
42
|
+
loop do
|
43
|
+
chunk = io.read(CHUNK_SIZE)
|
44
|
+
|
45
|
+
break unless chunk
|
46
|
+
|
47
|
+
yielder << chunk
|
48
|
+
end
|
35
49
|
end
|
36
50
|
|
37
51
|
begin
|
data/lib/tus/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tus-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Mochalov (factyy)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|