Sha256: 5d605052fda63e4a790d7b834ef510443303191c4b14927d609bb6e436838d08

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

module Fluent
  class S3Input
    class GzipCommandExtractor < Extractor
      S3Input.register_extractor('gzip_command', self)

      config_param :command_parameter, :string, :default => '-dc'

      def configure(conf)
        super
        check_command('gzip')
      end

      def ext
        'gz'.freeze
      end

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

      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
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fluent-plugin-s3-0.8.8 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.7 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.6 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.5 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.4 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.3 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.2 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.1 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.0 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.8.0.rc1 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.7.2 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.7.1 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-0.7.0 lib/fluent/plugin/s3_extractor_gzip_command.rb