Method: FieldView::Upload.create

Defined in:
lib/fieldview/upload.rb

.create(auth_token, md5, content_length, content_type) ⇒ Object

Creates an upload with the specified items, all required. will return an a new upload object that has it’s ID which can be used to upload. See the constant “CONTENT_TYPES” for the list of known types



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fieldview/upload.rb', line 21

def self.create(auth_token, md5, content_length, content_type)
  if not self.valid_content_type?(content_type) then
    raise ArgumentError.new("content_type must be set to one of the following: #{CONTENT_TYPES.join(', ')}")
  end

  response = auth_token.execute_request!(:post, PATH,
    params: {
      "md5" => md5,
      "length" => content_length,
      "contentType" => content_type
  })

  Util.verify_response_with_code("Upload creation", response, 201)

  return new(response.http_body.gsub('"', ''), content_length, auth_token)
end