class TheCity::API::Request::MultipartWithFile
Constants
- CONTENT_TYPE
Public Instance Methods
call(env)
click to toggle source
# File lib/the_city/api/request/multipart_with_file.rb, line 9 def call(env) for key, value in env[:body] if value.respond_to?(:to_io) env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path) end end if env[:body].is_a?(::Hash) @app.call(env) end
Private Instance Methods
mime_type(path)
click to toggle source
# File lib/the_city/api/request/multipart_with_file.rb, line 20 def mime_type(path) case path when /\.jpe?g/i 'image/jpeg' when /\.gif$/i 'image/gif' when /\.png$/i 'image/png' else 'application/octet-stream' end end