lib/trubl/client.rb
# Perform an HTTP Multipart Form Request
Perform an HTTP Multipart Form Request
Perform an HTTP Multipart Form Request
def multipart_post(path, params={})
      raise ArgumentError.new("Must specify a valid file to include\nYou specified #{params[:data]}") unless File.exists?(params[:data])
      uri = full_uri(path)
      payload = { 'tout[data]' => Faraday::UploadIO.new(params[:data], 'video/mp4')}.merge(params)
      Trubl.logger.info { "Trubl::Client   multipart post-ing #{uri.to_s} (content omitted)" }
      Faraday.new(url: uri) do |faraday|
        faraday.headers = options
        faraday.request :multipart
        faraday.response :logger
        faraday.adapter Faraday.default_adapter
      end.post(uri.to_s, payload).tap do |response|
        if !response.status =~ /20[0-9]/
          Trubl.logger.fatal { "Trubl::Client   multipart post-ing #{uri.to_s} #{response.code} #{response.parsed_response}" }
        end
      end
    end
def multipart_post ( path , params = { } ) raise ArgumentError . new ( "Must specify a valid file to include\nYou specified #{params[:data]}" ) unless File . exists? ( params [ :data ] ) uri = full_uri ( path ) payload = { 'tout[data]' => Faraday :: UploadIO . new ( params [ :data ] , 'video/mp4' ) } . merge ( params ) Trubl . logger . info { "Trubl::Client   multipart post-ing #{uri.to_s} (content omitted)" } Faraday . new ( url : uri ) do | faraday | faraday . headers = options faraday . request :multipart faraday . response :logger faraday . adapter Faraday . default_adapter end . post ( uri . to_s , payload ) . tap do | response | if ! response . status =~ / 20[0-9] / Trubl . logger . fatal { "Trubl::Client   multipart post-ing #{uri.to_s} #{response.code} #{response.parsed_response}" } end end end
Perform an HTTP Multipart Form Request
Perform an HTTP Multipart Form Request
path
params