Class: Fluent::GCS::GZipObjectCreator

Inherits:
ObjectCreator show all
Defined in:
lib/fluent/plugin/gcs/object_creator.rb

Instance Method Summary collapse

Methods inherited from ObjectCreator

#create

Constructor Details

#initialize(transcoding) ⇒ GZipObjectCreator

Returns a new instance of GZipObjectCreator.



83
84
85
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 83

def initialize(transcoding)
  @transcoding = transcoding
end

Instance Method Details

#content_encodingObject



91
92
93
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 91

def content_encoding
  @transcoding ? "gzip" : nil
end

#content_typeObject



87
88
89
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 87

def content_type
  @transcoding ? "text/plain" : "application/gzip"
end

#file_extensionObject



95
96
97
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 95

def file_extension
  "gz"
end

#write(chunk, io) ⇒ Object



99
100
101
102
103
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 99

def write(chunk, io)
  writer = Zlib::GzipWriter.new(io)
  chunk.write_to(writer)
  writer.finish
end