Module: HTTPX::Transcoder::Multipart::MimeTypeDetector
- Defined in:
- lib/httpx/transcoder/multipart/mime_type_detector.rb
Constant Summary collapse
- DEFAULT_MIMETYPE =
"application/octet-stream"
- MAGIC_NUMBER =
256 * 1024
Instance Method Summary collapse
Instance Method Details
#call(_, _) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/httpx/transcoder/multipart/mime_type_detector.rb', line 14 def call(file, _) return nil if file.eof? # FileMagic returns "application/x-empty" for empty files mime = FileMagic.open(FileMagic::MAGIC_MIME_TYPE) do |filemagic| filemagic.buffer(file.read(MAGIC_NUMBER)) end file.rewind mime end |