Class: TelestreamCloud::Uploader
- Inherits:
-
Object
- Object
- TelestreamCloud::Uploader
- Defined in:
- lib/telestream_cloud/uploader.rb,
lib/telestream_cloud/uploader/file_reader.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FileReader, MissingPartError, UploadError
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#video ⇒ Object
readonly
Returns the value of attribute video.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Uploader
constructor
A new instance of Uploader.
- #success? ⇒ Boolean
- #upload(retries = 5) ⇒ Object
Constructor Details
#initialize(options) ⇒ Uploader
Returns a new instance of Uploader.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/telestream_cloud/uploader.rb', line 16 def initialize() file = .delete(:file) { |key| fail KeyError, "key not found: #{key}" } @reader = FileReader.new(file) defaults = { file_size: reader.size, file_name: reader.name, multi_chunk: true } @params = defaults.merge() @status = :ready end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/telestream_cloud/uploader.rb', line 9 def error @error end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
9 10 11 |
# File 'lib/telestream_cloud/uploader.rb', line 9 def reader @reader end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/telestream_cloud/uploader.rb', line 9 def status @status end |
#video ⇒ Object (readonly)
Returns the value of attribute video.
9 10 11 |
# File 'lib/telestream_cloud/uploader.rb', line 9 def video @video end |
Class Method Details
.upload(options) ⇒ Object
11 12 13 14 |
# File 'lib/telestream_cloud/uploader.rb', line 11 def self.upload() retries = .delete(:retries) new().tap { |x| x.upload(*[retries].compact) }.video end |
Instance Method Details
#success? ⇒ Boolean
46 47 48 |
# File 'lib/telestream_cloud/uploader.rb', line 46 def success? status == :success end |
#upload(retries = 5) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/telestream_cloud/uploader.rb', line 31 def upload(retries = 5) count = 0 begin count += 1 upload! fail MissingPartError unless success? rescue => e @error = e retry if count < retries self.status = :failed end success? end |