module HTTPX::Transcoder::Multipart::MimeTypeDetector

  1. lib/httpx/transcoder/multipart/mime_type_detector.rb

Methods

Public Instance

  1. call

Constants

DEFAULT_MIMETYPE = "application/octet-stream"  
MAGIC_NUMBER = 256 * 1024  

Public Instance methods

call(file, _)
[show source]
   # File lib/httpx/transcoder/multipart/mime_type_detector.rb
14 def call(file, _)
15   return nil if file.eof? # FileMagic returns "application/x-empty" for empty files
16 
17   mime = FileMagic.open(FileMagic::MAGIC_MIME_TYPE) do |filemagic|
18     filemagic.buffer(file.read(MAGIC_NUMBER))
19   end
20 
21   file.rewind
22 
23   mime
24 end