Method: Aliyun::OSS::Protocol#append_object
- Defined in:
- lib/aliyun/oss/protocol.rb
#append_object(bucket_name, object_name, position, opts = {}) {|HTTP::StreamWriter| ... } ⇒ Integer
Note:
-
Can not append to a “Normal Object”
-
The position must equal to the object’s size before append
-
The :content_type is only used when the object is created
Append to an object of a bucket. Create an “Appendable Object” if the object does not exist. A block is required to provide the appending data.
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/aliyun/oss/protocol.rb', line 551 def append_object(bucket_name, object_name, position, opts = {}, &block) logger.debug("Begin append object, bucket: #{bucket_name}, object: "\ "#{object_name}, position: #{position}, options: #{opts}") sub_res = {'append' => nil, 'position' => position} headers = {'Content-Type' => opts[:content_type]} (opts[:metas] || {}) .each { |k, v| headers["x-oss-meta-#{k.to_s}"] = v.to_s } h, _ = @http.post( {:bucket => bucket_name, :object => object_name, :sub_res => sub_res}, {:headers => headers, :body => HTTP::StreamPayload.new(&block)}) logger.debug('Done append object') wrap(h[:x_oss_next_append_position], &:to_i) || -1 end |