Class: TelestreamCloud::Tts::Uploader::FileUploadSession

Inherits:
Object
  • Object
show all
Defined in:
lib/telestream_cloud_tts/uploader.rb

Direct Known Subclasses

ConcurrentFileUploadSession

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader, path, tag = nil) ⇒ FileUploadSession

Returns a new instance of FileUploadSession.



44
45
46
47
48
49
# File 'lib/telestream_cloud_tts/uploader.rb', line 44

def initialize(uploader, path, tag = nil)
  @uploader = uploader
  @reader = FileReader.new(path)
  @tag = tag
  @status = :ready
end

Instance Attribute Details

#readerObject (readonly)

Returns the value of attribute reader.



42
43
44
# File 'lib/telestream_cloud_tts/uploader.rb', line 42

def reader
  @reader
end

#tagObject (readonly)

Returns the value of attribute tag.



42
43
44
# File 'lib/telestream_cloud_tts/uploader.rb', line 42

def tag
  @tag
end

#uploaderObject (readonly)

Returns the value of attribute uploader.



42
43
44
# File 'lib/telestream_cloud_tts/uploader.rb', line 42

def uploader
  @uploader
end

Instance Method Details

#paramsObject



55
56
57
58
59
60
61
62
63
# File 'lib/telestream_cloud_tts/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

Returns:

  • (Boolean)


51
52
53
# File 'lib/telestream_cloud_tts/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_tts/uploader.rb', line 65

def upload!
  reader.reopen

  upload_chunks(missing_parts)

  raise MissingPartError unless missing_parts.empty?

  @status = :success
ensure
  reader.close
end