Class: Vimeo::Advanced::Upload

Inherits:
Base
  • Object
show all
Defined in:
lib/vimeo/advanced/upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#authorize_url, #get_access_token, #get_request_token, #initialize

Methods included from CreateApiMethod

#create_api_method

Constructor Details

This class inherits a constructor from Vimeo::Advanced::Base

Class Method Details

.create_json_manifest(md5s) ⇒ Object

TODO: Make this more flexible for split uploads?



51
52
53
# File 'lib/vimeo/advanced/upload.rb', line 51

def self.create_json_manifest(md5s)
  { :files => md5s.map { |md5| { :md5 => md5 } } }.to_json
end

Instance Method Details

#upload(auth_token, file_path, ticket_id, end_point) ⇒ Object

Upload file to vimeo with ticket_id and auth_token Returns the json manifest necessary to confirm the upload.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vimeo/advanced/upload.rb', line 27

def upload(auth_token, file_path, ticket_id, end_point)
  params = {
    :auth_token => auth_token,
    :ticket_id  => ticket_id
  }
  params[:api_sig] = generate_api_sig params
  
  params.merge!({ :file_data => File.open(file_path) })
  
  client = HTTPClient.new
  response = client.post(end_point, params)
  md5 = response.content

  self.class.create_json_manifest(md5)
end