Class: TelestreamCloud::Qc::Uploader::FileUploadSession
- Inherits:
-
Object
- Object
- TelestreamCloud::Qc::Uploader::FileUploadSession
- Defined in:
- lib/telestream_cloud_qc/uploader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#uploader ⇒ Object
readonly
Returns the value of attribute uploader.
Instance Method Summary collapse
-
#initialize(uploader, path, tag = nil) ⇒ FileUploadSession
constructor
A new instance of FileUploadSession.
- #params ⇒ Object
- #success? ⇒ Boolean
- #upload! ⇒ Object
Constructor Details
#initialize(uploader, path, tag = nil) ⇒ FileUploadSession
Returns a new instance of FileUploadSession.
44 45 46 47 48 49 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 44 def initialize(uploader, path, tag = nil) @uploader = uploader @reader = FileReader.new(path) @tag = tag @status = :ready end |
Instance Attribute Details
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
42 43 44 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 42 def reader @reader end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
42 43 44 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 42 def tag @tag end |
#uploader ⇒ Object (readonly)
Returns the value of attribute uploader.
42 43 44 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 42 def uploader @uploader end |
Instance Method Details
#params ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 55 def params upload_params = { file_size: reader.size, file_name: reader.name } upload_params[:tag] = @tag if @tag upload_params end |
#success? ⇒ Boolean
51 52 53 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 51 def success? @status == :success end |
#upload! ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/telestream_cloud_qc/uploader.rb', line 65 def upload! reader.reopen upload_chunks(missing_parts) raise MissingPartError unless missing_parts.empty? @status = :success ensure reader.close end |