module Github::Repos::Downloads
def upload(resource, filename)
* :size - Required number - size of file in bytes.
* resource - Required Hashie::Mash -resource of the create_download call
= Parameters
the response object as an argument to upload method.
Github::Repos::Downloads#create_download. This can be done by passing
Upload a file to Amazon, using the reponse instance from
def upload(resource, filename) _validate_presence_of resource, filename raise ArgumentError, 'Need to provied resource of Github::Repose::Downloads#create_download call' unless resource.is_a? Hashie::Mash REQUIRED_S3_PARAMS.each do |key| raise ArgumentError, "Expected following key: #{key}" unless resource.respond_to?(key) end # TODO use ordered hash if Ruby < 1.9 hash = ruby_18 { require 'active_support' ActiveSupport::OrderedHash.new } || ruby_19 { Hash.new } mapped_params = { 'key' => resource.path, 'acl' => resource.acl, 'success_action_status' => SUCCESS_STATUS, 'Filename' => resource.name, 'AWSAccessKeyId' => resource.accesskeyid, 'Policy' => resource.policy, 'Signature' => resource.signature, 'Content-Type' => resource.mime_type, 'file' => prepend_at_for(filename.to_s) } post('', mapped_params, { :url => resource.s3_url }) end