Class: QcloudCos::Multipart
- Inherits:
-
Object
- Object
- QcloudCos::Multipart
- Defined in:
- lib/qcloud_cos/multipart.rb
Instance Attribute Summary collapse
-
#authorization ⇒ Object
readonly
Returns the value of attribute authorization.
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#dst_path ⇒ Object
readonly
Returns the value of attribute dst_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#src_path ⇒ Object
readonly
Returns the value of attribute src_path.
Instance Method Summary collapse
-
#initialize(dst_path, src_path, options = {}) ⇒ Multipart
constructor
A new instance of Multipart.
- #upload(&block) ⇒ Object
Constructor Details
permalink #initialize(dst_path, src_path, options = {}) ⇒ Multipart
Returns a new instance of Multipart.
5 6 7 8 9 10 11 |
# File 'lib/qcloud_cos/multipart.rb', line 5 def initialize(dst_path, src_path, = {}) @dst_path = dst_path @src_path = src_path @options = @bucket = .delete(:bucket) @authorization = .delete(:authorization) end |
Instance Attribute Details
permalink #authorization ⇒ Object (readonly)
Returns the value of attribute authorization.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def @authorization end |
permalink #bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def bucket @bucket end |
permalink #dst_path ⇒ Object (readonly)
Returns the value of attribute dst_path.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def dst_path @dst_path end |
permalink #options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def @options end |
permalink #result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def result @result end |
permalink #src_path ⇒ Object (readonly)
Returns the value of attribute src_path.
3 4 5 |
# File 'lib/qcloud_cos/multipart.rb', line 3 def src_path @src_path end |
Instance Method Details
permalink #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 |