Method: QcloudCos::Multipart#upload

Defined in:
lib/qcloud_cos/multipart.rb

#upload(&block) ⇒ Object

[View source]

13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/qcloud_cos/multipart.rb', line 13

def upload(&block)
  init_multipart
  return if complete?
  fail QcloudCos::MissingSessionIdError unless session

  offset = @result['offset'] || 0

  while offset < filesize
    filecontent = IO.read(src_path, slice_size, offset)
    break if upload_part(offset, filecontent, &block)
    offset += slice_size
  end
end