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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c78e0691674c67ddd260b6fcd7bfdaa63969b4ac607a407c0e2db0cf2764faf
4
- data.tar.gz: 0fd974c57a0cb41d2ef89a4a170334d50400942ab8c746a9234c292d73e4f345
3
+ metadata.gz: 8b8108a255ddf2b7ce299020f00471c4fdf739e989d1c284a85dd4c7917e0716
4
+ data.tar.gz: efef76c400ef70c1c198d2bb33057e9ebd4c8488450650e46262422e9f52e739
5
5
  SHA512:
6
- metadata.gz: '0649be4eaf989d832a1efb509b0a2790493fe2e44b60f736c26ed8ebd7eed61d8d01672e06ece5c124d7bfdffb4e4abdd3b55a0f2fc5ad61577a80632710c295'
7
- data.tar.gz: 92e3d0c5477479f34a8cf268cfbfd8f846edf964a595411b117f2593039bdcb8788179c0bc8941f4adfce2c3dc9ac352322a56be94e9d404f61d546c9c5bb08f
6
+ metadata.gz: a1a39c5b3c43fcd4c14900165fdba237491c55b6477265440895c13e9550bce42c7a321fb4fb8b3c9eb24fa81770998bc7e145af953059a202465da3566af817
7
+ data.tar.gz: ad6d39924d26cf257a3c01a5a7910df925707bf8987b034f8a92368ebeaec074c7ae57f964ddcba39a0d5c1e9e9d6f1f3af08093891d319d874fd392f789fb7d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vimeorb (0.1.1)
4
+ vimeorb (0.1.2)
5
5
  faraday (~> 2.0)
6
6
 
7
7
  GEM
@@ -24,4 +24,4 @@ DEPENDENCIES
24
24
  vimeorb!
25
25
 
26
26
  BUNDLED WITH
27
- 2.3.6
27
+ 2.3.5
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Vimeo
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimeorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry