vimeorb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +4 -0
- data/lib/vimeo/resource.rb +0 -2
- data/lib/vimeo/resources/videos.rb +29 -0
- data/lib/vimeo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b8108a255ddf2b7ce299020f00471c4fdf739e989d1c284a85dd4c7917e0716
|
4
|
+
data.tar.gz: efef76c400ef70c1c198d2bb33057e9ebd4c8488450650e46262422e9f52e739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a39c5b3c43fcd4c14900165fdba237491c55b6477265440895c13e9550bce42c7a321fb4fb8b3c9eb24fa81770998bc7e145af953059a202465da3566af817
|
7
|
+
data.tar.gz: ad6d39924d26cf257a3c01a5a7910df925707bf8987b034f8a92368ebeaec074c7ae57f964ddcba39a0d5c1e9e9d6f1f3af08093891d319d874fd392f789fb7d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,10 @@ params = {title: "New Title"}
|
|
35
35
|
|
36
36
|
# Delete a Video
|
37
37
|
@client.videos.delete(id: "abc123")
|
38
|
+
|
39
|
+
# Upload a Video using resumable uploads
|
40
|
+
# This splits the file into 128MB chunks while uploading
|
41
|
+
@client.videos.upload(file: File.new("my_video.mp4"))
|
38
42
|
```
|
39
43
|
|
40
44
|
## Contributing
|
data/lib/vimeo/resource.rb
CHANGED
@@ -46,8 +46,6 @@ module Vimeo
|
|
46
46
|
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["error"]["message"]}'"
|
47
47
|
when 503
|
48
48
|
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["error"]["message"]}'"
|
49
|
-
when 204
|
50
|
-
return true
|
51
49
|
end
|
52
50
|
|
53
51
|
response
|
@@ -16,5 +16,34 @@ module Vimeo
|
|
16
16
|
return true if response.success
|
17
17
|
end
|
18
18
|
|
19
|
+
# Upload a new Video
|
20
|
+
# Uses the Resumable Upload feature - https://developer.vimeo.com/api/upload/videos#resumable-approach
|
21
|
+
# It splits the file up into 128MB chunks and uploads them until complete
|
22
|
+
def upload(file:, debug: false)
|
23
|
+
tus = post_request("me/videos", body: {upload: {approach: 'tus', size: file.size.to_s}})
|
24
|
+
|
25
|
+
headers = {'Content-Type' => 'application/offset+octet-stream'}
|
26
|
+
headers['Tus-Resumable'] = '1.0.0'
|
27
|
+
headers['Upload-Offset'] = '0'
|
28
|
+
file.rewind
|
29
|
+
|
30
|
+
# 128MB
|
31
|
+
split = 128000000
|
32
|
+
|
33
|
+
begin
|
34
|
+
video_content = file.read(split)
|
35
|
+
@response = patch_request(tus.body["upload"]["upload_link"], body: video_content, headers: headers)
|
36
|
+
|
37
|
+
offset = @response.headers['upload-offset']
|
38
|
+
headers['Upload-Offset'] = offset
|
39
|
+
|
40
|
+
if debug
|
41
|
+
puts "* #{offset}/#{file.size}"
|
42
|
+
end
|
43
|
+
end while offset.to_i != file.size
|
44
|
+
|
45
|
+
Video.new(tus.body)
|
46
|
+
end
|
47
|
+
|
19
48
|
end
|
20
49
|
end
|
data/lib/vimeo/version.rb
CHANGED