Sha256: 66c26998882c4c2734cd90ebd7e41bd0ad42d020c9722cb63646afd28dcf5461

Contents?: true

Size: 448 Bytes

Versions: 5

Compression:

Stored size: 448 Bytes

Contents

require 'net/http/post/multipart'

module HTTPMultiPart
  def multipart_post(url, params = {})
    unless params.has_key?(:file)
      post(url, params)
    end

    url = URI.parse(base_uri + url)

    req = Net::HTTP::Post::Multipart.new(url.path, { 
      file: UploadIO.new(File.open(params[:file]), 'file'), 
      body: params[:body] })

    https = Net::HTTP.new(url.host, url.port)
    https.use_ssl = true
    https.request(req)
  end
end

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/kraken-io-0.1.3/lib/kraken-io/http_multi_part.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/kraken-io-0.1.3/lib/kraken-io/http_multi_part.rb
kraken-io-0.1.3 lib/kraken-io/http_multi_part.rb
kraken-io-0.1.2 lib/kraken-io/http_multi_part.rb
kraken-io-0.1.1 lib/kraken-io/http_multi_part.rb