Class: BunnyStream::Storage
- Inherits:
-
Object
- Object
- BunnyStream::Storage
- Defined in:
- lib/bunny_stream/storage.rb
Class Method Summary collapse
- .create_video(values) ⇒ Object
- .delete_video(video_id) ⇒ Object
- .get_video(video_id) ⇒ Object
- .upload_video(video_id, file) ⇒ Object
Class Method Details
.create_video(values) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bunny_stream/storage.rb', line 3 def self.create_video(values) response = BunnyStream.http().post( "https://video.bunnycdn.com/library/#{BunnyStream.config.library_id}/videos", json: values ) response_body = Oj.load(response.body.to_s) if response.status == 200 response_body["guid"] elsif response_body.is_a?(Hash) response_body["errors"] end end |
.delete_video(video_id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bunny_stream/storage.rb', line 48 def self.delete_video(video_id) response = BunnyStream.http().delete( "https://video.bunnycdn.com/library/#{BunnyStream.config.library_id}/videos/#{video_id}" ) response_body = Oj.load(response.body.to_s) if response.status == 200 true else response_body["errors"] end end |
.get_video(video_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bunny_stream/storage.rb', line 34 def self.get_video(video_id) response = BunnyStream.http().get( "https://video.bunnycdn.com/library/#{BunnyStream.config.library_id}/videos/#{video_id}" ) response_body = Oj.load(response.body.to_s) if response.status == 200 response_body else nil end end |
.upload_video(video_id, file) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bunny_stream/storage.rb', line 18 def self.upload_video(video_id, file) response = BunnyStream.http().put( "https://video.bunnycdn.com/library/#{BunnyStream.config.library_id}/videos/#{video_id}", body: file ) response_body = Oj.load(response.body.to_s) if response.status == 200 true else response_body["errors"] end end |