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.



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

def initialize(transcoding)
  @transcoding = transcoding
end

Instance Method Details

#content_encodingObject



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

def content_encoding
  @transcoding ? "gzip" : nil
end

#content_typeObject



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

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

#file_extensionObject



65
66
67
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 65

def file_extension
  "gz"
end

#write(chunk, io) ⇒ Object



69
70
71
72
73
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 69

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