class Fluent::Plugin::S3Input::GzipCommandExtractor

Public Instance Methods

configure(conf) click to toggle source
# File lib/fluent/plugin/s3_extractor_gzip_command.rb, line 8
def configure(conf)
  super
  check_command('gzip')
end
content_type() click to toggle source
# File lib/fluent/plugin/s3_extractor_gzip_command.rb, line 17
def content_type
  'application/x-gzip'.freeze
end
ext() click to toggle source
# File lib/fluent/plugin/s3_extractor_gzip_command.rb, line 13
def ext
  'gz'.freeze
end
extract(io) click to toggle source
# File lib/fluent/plugin/s3_extractor_gzip_command.rb, line 21
def extract(io)
  path = if io.respond_to?(:path)
           io.path
         else
           temp = Tempfile.new("gzip-temp")
           temp.write(io.read)
           temp.close
           temp.path
         end

  stdout, succeeded = Open3.capture2("gzip #{@command_parameter} #{path}")
  if succeeded
    stdout
  else
    log.warn "failed to execute gzip command. Fallback to GzipReader. status = #{succeeded}"
    begin
      io.rewind
      Zlib::GzipReader.wrap(io) do |gz|
        gz.read
      end
    end
  end
end