Sha256: f0f2429c3530c6eb61f4c1fc2155384afa557246690b22720da673c47f321939

Contents?: true

Size: 1.05 KB

Versions: 52

Compression:

Stored size: 1.05 KB

Contents

module Fluent::Plugin
  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

52 entries across 52 versions & 3 rubygems

Version Path
fluent-plugin-s3-1.1.10 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.9 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.8 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.7 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.6 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.5 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.4 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.3 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.2 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.1 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.1.0 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.0.0 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.0.0.rc8 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.8 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.7 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-1.0.0.rc7 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.6 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.5 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.4 lib/fluent/plugin/s3_extractor_gzip_command.rb
fluent-plugin-s3-hubspot-1.0.0.rc6.3 lib/fluent/plugin/s3_extractor_gzip_command.rb