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.



45
46
47
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 45

def initialize(transcoding)
  @transcoding = transcoding
end

Instance Method Details

#content_encodingObject



53
54
55
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 53

def content_encoding
  @transcoding ? "gzip" : nil
end

#content_typeObject



49
50
51
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 49

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

#file_extensionObject



57
58
59
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 57

def file_extension
  "gz"
end

#write(chunk, io) ⇒ Object



61
62
63
64
65
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 61

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