Class: Bkblz::V1::UploadPartRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/bkblz/v1/upload_part.rb

Constant Summary collapse

REQUIRED_HEADERS =
{
                    :"Authorization" => nil,
                    :"Content-Length" => nil,
                    :"Content-Type" => 'application/octet-stream',
                    :"X-Bz-Part-Number" => nil, # a value in [1..10000]
                    :"X-Bz-Content-Sha1" => nil
}

Instance Method Summary collapse

Methods inherited from Request

response_class, #send, url_suffix

Constructor Details

#initialize(upload_part_auth, io, chunk_number, chunk_size) ⇒ UploadPartRequest

Returns a new instance of UploadPartRequest.

Parameters:

  • is (chunk_number)

    a value in [0…9999]



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bkblz/v1/upload_part.rb', line 24

def initialize(upload_part_auth, io, chunk_number, chunk_size)
  @upload_url = upload_part_auth.upload_url
  @body_chunk = read_chunk(io, chunk_number, chunk_size)
  @headers = REQUIRED_HEADERS.dup

  part_number = chunk_number + 1
  @headers[:"Authorization"] = upload_part_auth.authorization_token
  @headers[:"Content-Length"] = @body_chunk.size
  @headers[:"X-Bz-Part-Number"] = part_number
  @headers[:"X-Bz-Content-Sha1"] = Digest::SHA1.hexdigest @body_chunk
end

Instance Method Details

#build_request(session) ⇒ Object



36
37
38
# File 'lib/bkblz/v1/upload_part.rb', line 36

def build_request(session)
  session.create_post @upload_url, @body_chunk, @headers
end