Sha256: 2316a8ee17544bea6107b50bd00debac1ef3c95427c9eb7c4c9f109336fa4a09
Contents?: true
Size: 1001 Bytes
Versions: 3
Compression:
Stored size: 1001 Bytes
Contents
module S3Multipart class Http require 'net/http' attr_accessor :method, :path, :body, :headers, :response def initialize(method, path, options) @method = method @path = path @headers = options[:headers] @body = options[:body] end class << self def get(path, options={}) new(:get, path, options).perform end def post(path, options={}) new(:post, path, options).perform end def put(path, options={}) new(:put, path, options).perform end end def perform request = request_class.new(path) headers.each do |key, val| request[key.to_s.split("_").map(&:capitalize).join("-")] = val end request.body = body if body @response = http.request(request) end private def http Net::HTTP.new('bitcast-bucket.s3.amazonaws.com', 80) end def request_class Net::HTTP.const_get(method.to_s.capitalize) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
s3_multipart-0.0.4 | lib/s3_multipart/http/net_http.rb |
s3_multipart-0.0.3 | lib/s3_multipart/http/net_http.rb |
s3_multipart-0.0.2 | lib/s3_multipart/http/net_http.rb |