def post_io_streaming(api_method, file, content_type, parameters)
      parameters.merge!({"token" => @token})

      body = {}
      body.merge!({:method => api_method})
      body.merge!({:params => parameters})

      # Brightcove requires that the JSON-RPC call absolutely
      # be the first part of a multi-part POST like create_video.
      if RUBY_VERSION >= '1.9'
        payload = {}
      else
        payload = OrderedHash.new
      end

      url = URI.parse(@write_api_url)
      response = nil

      payload[:json] = body.to_json

      if file.is_a?(UploadIO)
        payload[:file] = file
      else
        filename = file.respond_to?(:base_uri) ? File.basename(file.base_uri.to_s) : File.basename(file.path) rescue nil
        payload[:file] = UploadIO.new(file, content_type, filename)
      end

      request = Net::HTTP::Post::Multipart.new(url.path, payload)

      response = Net::HTTP.start(url.host, url.port, :use_ssl => true) do |http|
        http.read_timeout = @timeout if @timeout
        http.open_timeout = @open_timeout if @open_timeout
        http.request(request)
      end

      JSON.parse(response.body)
    end
def post_io_streaming(api_method, file, content_type, parameters)
      parameters.merge!({"token" => @token})

      body = {}
      body.merge!({:method => api_method})
      body.merge!({:params => parameters})

      # Brightcove requires that the JSON-RPC call absolutely
      # be the first part of a multi-part POST like create_video.
      if RUBY_VERSION >= '1.9'
        payload = {}
      else
        payload = OrderedHash.new
      end

      url = URI.parse(@write_api_url)
      response = nil

      payload[:json] = body.to_json

      if file.is_a?(UploadIO)
        payload[:file] = file
      else
        filename = file.respond_to?(:base_uri) ? File.basename(file.base_uri.to_s) : File.basename(file.path) rescue nil
        payload[:file] = UploadIO.new(file, content_type, filename)
      end

      request = Net::HTTP::Post::Multipart.new(url.path, payload)

      response = Net::HTTP.start(url.host, url.port, :use_ssl => true) do |http|
        http.read_timeout = @timeout if @timeout
        http.open_timeout = @open_timeout if @open_timeout
        http.request(request)
      end

      JSON.parse(response.body)
    end
Post a file IO object via HTTP streaming to the Brightcove API, e.g. uploading video.

 @param api_method [String] Brightcove API method.
 @param file [File handle] File handle of file to be uploaded.
 @param parameters [Hash] Optional hash containing parameter names and values.