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.



47
48
49
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 47

def initialize(transcoding)
  @transcoding = transcoding
end

Instance Method Details

#content_encodingObject



55
56
57
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 55

def content_encoding
  @transcoding ? "gzip" : nil
end

#content_typeObject



51
52
53
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 51

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

#file_extensionObject



59
60
61
# File 'lib/fluent/plugin/gcs/object_creator.rb', line 59

def file_extension
  "gz"
end

#write(chunk, io) ⇒ Object



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

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