Sha256: c34367ade43c141d5440d0f41ce24539242082b59f526813cbdd8a65eef0f653
Contents?: true
Size: 633 Bytes
Versions: 3
Compression:
Stored size: 633 Bytes
Contents
require 'faraday' # @private module Faraday # @private class Request::Multipart2 < Faraday::Middleware def call(env) if env[:body].is_a?(Hash) env[:body].each do |key, value| if value.is_a?(File) env[:body][key] = Faraday::UploadIO.new(value, mime_type(value), value.path) end end end @app.call(env) end private def mime_type(file) case file.path when /\.jpe?g/i then 'image/jpeg' when /\.gif$/i then 'image/gif' when /\.png$/i then 'image/png' else 'application/octet-stream' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-slideshare-0.1.7 | lib/faraday/multipart.rb |
ruby-slideshare-0.1.6 | lib/faraday/multipart.rb |
ruby-slideshare-0.1.5 | lib/faraday/multipart.rb |