Parent

Methods

Class/Module Index [+]

Quicksearch

Github::S3Uploader

Constants

REQUIRED_S3_PARAMS
SUCCESS_STATUS

Status code for successful upload to Amazon S3 service

Attributes

filename[RW]
resource[RW]

Public Class Methods

new(resource, filename) click to toggle source
# File lib/github_api/s3_uploader.rb, line 22
def initialize(resource, filename)
  @resource = resource
  @filename = filename
end

Public Instance Methods

send() click to toggle source
# File lib/github_api/s3_uploader.rb, line 27
def send
  REQUIRED_S3_PARAMS.each do |key|
    unless resource.respond_to?(key)
      raise ArgumentError, "Expected following key: #{key}"
    end
  end

  mapped_params = Github::CoreExt::OrderedHash[
    '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', Faraday::UploadIO.new(filename, 'application/octet-stream')
  ]

  http = Faraday.new do |builder|
    builder.request :multipart
    builder.use Github::Response::Xmlize
    builder.adapter :net_http
  end

  http.post resource.s3_url, mapped_params
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.