class ArchiveUploader::Curb

Public Class Methods

new(options={}) click to toggle source
# File lib/archive_uploader/curb.rb, line 3
def initialize(options={})
  @options = options
  @curl = Curl::Easy.new(@options[:url])
  check_for_auth
end

Public Instance Methods

check_for_auth() click to toggle source
# File lib/archive_uploader/curb.rb, line 14
def check_for_auth
  return unless @options[:auth]
  if @options[:auth]._method == :basic
    @curl.http_auth_types = :basic
    @curl.username = @options[:auth].user
    @curl.password = @options[:auth].password
  end
end
perform!() click to toggle source
# File lib/archive_uploader/curb.rb, line 9
def perform!
  @curl.multipart_form_post = true
  @curl.http_post(*post_data)
end
post_data() click to toggle source
# File lib/archive_uploader/curb.rb, line 23
def post_data
  fields = @options[:fields].collect do |field, value|
    Curl::PostField.content("file[#{field}]", value)
  end
  [Curl::PostField.file('file[file]', @options[:file])] + fields
end