Class: Fluent::Plugin::S3Input::GzipExtractor

Inherits:
Extractor
  • Object
show all
Defined in:
lib/fluent/plugin/in_s3.rb

Instance Attribute Summary

Attributes inherited from Extractor

#log

Instance Method Summary collapse

Methods inherited from Extractor

#configure, #initialize

Constructor Details

This class inherits a constructor from Fluent::Plugin::S3Input::Extractor

Instance Method Details

#content_typeObject



358
359
360
# File 'lib/fluent/plugin/in_s3.rb', line 358

def content_type
  'application/x-gzip'.freeze
end

#extObject



354
355
356
# File 'lib/fluent/plugin/in_s3.rb', line 354

def ext
  'gz'.freeze
end

#extract(io) ⇒ Object



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/fluent/plugin/in_s3.rb', line 365

def extract(io)
  parts = []
  loop do
    unused = nil
    Zlib::GzipReader.wrap(io) do |gz|
      parts << gz.read
      unused = gz.unused
      gz.finish
    end
    io.pos -= unused ? unused.length : 0
    break if io.eof?
  end
  io.close
  parts.join
end