Class: Bkblz::V1::StartLargeFileRequest

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

Instance Method Summary collapse

Methods inherited from Request

response_class, #send, url_suffix

Constructor Details

#initialize(bucket_id, file_name, last_modified_millis = nil, file_sha = nil, content_type = 'b2/x-auto', **file_info) ⇒ StartLargeFileRequest

Returns a new instance of StartLargeFileRequest.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bkblz/v1/start_large_file.rb', line 15

def initialize(bucket_id, file_name, last_modified_millis=nil,
    file_sha=nil, content_type='b2/x-auto', **file_info)
  # Both of the following are recommended here:
  # https://www.backblaze.com/b2/docs/b2_start_large_file.html
  if last_modified_millis
    # must be a string
    file_info[:src_last_modified_millis] = last_modified_millis.to_s
  end
  if file_sha
    file_info[:large_file_sha1] = file_sha
  end

  @body = {
    :bucket_id => bucket_id,
    :file_name => file_name,
    :content_type => content_type,
    :file_info => file_info
  }
end

Instance Method Details

#build_request(session) ⇒ Object



35
36
37
# File 'lib/bkblz/v1/start_large_file.rb', line 35

def build_request(session)
  session.create_post url(session), @body
end