Sha256: 88020f19c3d2b226e111268ca84eeba3a2a2254662ee303e864e7b229cd1b2a9
Contents?: true
Size: 649 Bytes
Versions: 63
Compression:
Stored size: 649 Bytes
Contents
require 'faraday' # @private module Faraday # @private class Request::MultipartWithFile < 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 'image/jpeg' when /\.gif$/i 'image/gif' when /\.png$/i 'image/png' else 'application/octet-stream' end end end end
Version data entries
63 entries across 63 versions & 4 rubygems