rstreamor 0.2.0 → 0.2.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/README.md +49 -8
- data/lib/rstreamor/file.rb +5 -1
- data/lib/rstreamor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a114369ba9a80a9fee20d8aca564c850c072fab9
|
4
|
+
data.tar.gz: d210db8229bd6674e5986ed0af1725a7a56978d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec343f4bebd927818fbc4818b7077ab99aaf05479d481c5f33e5fba0394d9f5c1bd55835144b4809caa5251bab63a3016ae425c4c1995099bb5df8964d053105
|
7
|
+
data.tar.gz: 8f5e8a1814c84547e62f2c2bb2fd85207055365b7eb23991d218b16faa2dc883a928d90e71c015c2bbd4b4434ff25983446e3b394b75cdb2e997bb8cecfa3b4f
|
data/README.md
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
# Rstreamor
|
2
|
-
|
2
|
+
Stream your data using HTTP/1.1 range requests and partial responses.
|
3
3
|
|
4
4
|
# Get Rstreamor
|
5
5
|
###### Directly from GitHub
|
6
6
|
```ruby
|
7
|
-
gem '
|
7
|
+
gem 'rstreamor', git: 'https://github.com/ndea/rstreamor.git', branch: 'master'
|
8
8
|
```
|
9
9
|
###### Rubygems
|
10
|
+
```ruby
|
11
|
+
gem 'rstreamor', '~> 0.2.1'
|
12
|
+
```
|
10
13
|
# Install
|
11
14
|
```ruby
|
12
15
|
bundle install
|
13
16
|
```
|
14
17
|
# Usage
|
15
|
-
|
18
|
+
In combination with Carrierwave
|
19
|
+
```ruby
|
20
|
+
class Profile < ActiveRecord::Base
|
21
|
+
mount_uploader :image_file, ProfileImageUploader
|
22
|
+
end
|
23
|
+
```
|
16
24
|
```ruby
|
17
25
|
class VideosController < ApplicationController
|
18
26
|
include Rstreamor
|
19
27
|
def show
|
20
|
-
stream @resource.
|
28
|
+
stream @resource.image_file
|
21
29
|
end
|
22
30
|
end
|
23
31
|
```
|
24
|
-
Please note that the file method of @resource is a mounted uploader of carrierwave.
|
25
|
-
|
26
32
|
Rstreamor takes care of the rest.
|
27
|
-
If you dont use Carrierwave as a file make sure your file has the following methods:
|
33
|
+
If you dont use Carrierwave as a file make sure your file method has the following methods defined:
|
28
34
|
- #data
|
29
35
|
- #content_type
|
30
36
|
|
@@ -35,7 +41,42 @@ Byte serving is the process of sending only a portion of an HTTP/1.1 message fro
|
|
35
41
|
Consider you have a large video or audio file on your server which needs to be served partially to your client. You don't want to send the whole file in one response (unless you want to download the file). Instead the client needs only partial content which he can view and request other partial content if needed. Rstreamor provides this byte serving mechanism defined in HTTP/1.1.
|
36
42
|
|
37
43
|
###### Example
|
38
|
-
|
44
|
+
Example of the request - response flow
|
45
|
+
Consider simple HTML5 video streaming.
|
46
|
+
```html
|
47
|
+
<video width="320" height="240" controls>
|
48
|
+
<source src="http://..." type="video/mp4">
|
49
|
+
Your browser does not support the video tag.
|
50
|
+
</video>
|
51
|
+
```
|
52
|
+
The first request fired by the client contains the following header
|
53
|
+
```bash
|
54
|
+
Range:bytes=0-
|
55
|
+
```
|
56
|
+
and requests the whole file from the server starting from 0 till end. The server then responds with the following headers
|
57
|
+
```bash
|
58
|
+
Accept-Ranges:bytes
|
59
|
+
Cache-Control:no-cache
|
60
|
+
Content-Disposition:inline
|
61
|
+
Content-Length:6642801
|
62
|
+
Content-Range:bytes 0-6642800/6642801
|
63
|
+
Content-Transfer-Encoding:binary
|
64
|
+
Content-Type:application/mp4
|
65
|
+
```
|
66
|
+
Now let's skip through our video and seek for a certain scene - the client now sends the following request header
|
67
|
+
```bash
|
68
|
+
Range:bytes=3303604-
|
69
|
+
```
|
70
|
+
And the server responds with the following response headers
|
71
|
+
```bash
|
72
|
+
Accept-Ranges:bytes
|
73
|
+
Cache-Control:no-cache
|
74
|
+
Content-Disposition:inline
|
75
|
+
Content-Length:3339197
|
76
|
+
Content-Range:bytes 3303604-6642800/6642801
|
77
|
+
Content-Transfer-Encoding:binary
|
78
|
+
Content-Type:application/mp4
|
79
|
+
```
|
39
80
|
# Contributing
|
40
81
|
|
41
82
|
1. Fork it ( https://github.com/ndea/regressor/fork )
|
data/lib/rstreamor/file.rb
CHANGED
data/lib/rstreamor/version.rb
CHANGED