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



400
401
402
# File 'lib/fluent/plugin/in_s3.rb', line 400

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

#extObject



396
397
398
# File 'lib/fluent/plugin/in_s3.rb', line 396

def ext
  'gz'.freeze
end

#extract(io) ⇒ Object



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/fluent/plugin/in_s3.rb', line 407

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