Class: Vimeo::VideosResource
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#delete(id:) ⇒ Object
14
15
16
17
|
# File 'lib/vimeo/resources/videos.rb', line 14
def delete(id:)
response = delete_request("videos/#{id}")
return true if response.success
end
|
#edit(id:, **params) ⇒ Object
9
10
11
12
|
# File 'lib/vimeo/resources/videos.rb', line 9
def edit(id:, **params)
response = patch_request("videos/#{id}", body: params)
Video.new(response.body)
end
|
#retrieve(id:) ⇒ Object
4
5
6
7
|
# File 'lib/vimeo/resources/videos.rb', line 4
def retrieve(id:)
response = get_request("videos/#{id}")
Video.new(response.body)
end
|
#upload(file:, debug: false) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/vimeo/resources/videos.rb', line 22
def upload(file:, debug: false)
tus = post_request("me/videos", body: {upload: {approach: 'tus', size: file.size.to_s}})
= {'Content-Type' => 'application/offset+octet-stream'}
['Tus-Resumable'] = '1.0.0'
['Upload-Offset'] = '0'
file.rewind
split = 128000000
begin
video_content = file.read(split)
@response = patch_request(tus.body["upload"]["upload_link"], body: video_content, headers: )
offset = @response.['upload-offset']
['Upload-Offset'] = offset
if debug
puts "* #{offset}/#{file.size}"
end
end while offset.to_i != file.size
Video.new(tus.body)
end
|