lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.4.0 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.4.1

- old
+ new

@@ -22,10 +22,11 @@ config_param :path, :string, :default => "" config_param :aws_key_id, :string, :default => nil config_param :aws_sec_key, :string, :default => nil config_param :s3_bucket, :string + config_param :s3_region, :string, :default => nil config_param :s3_endpoint, :string, :default => nil config_param :s3_object_key_format, :string, :default => "%{path}%{time_slice}_%{index}.%{file_extension}" config_param :store_as, :string, :default => "gzip" config_param :command_parameter, :string, :default => nil config_param :auto_create_bucket, :bool, :default => true @@ -97,11 +98,12 @@ options = {} if @aws_key_id && @aws_sec_key options[:access_key_id] = @aws_key_id options[:secret_access_key] = @aws_sec_key end - options[:s3_endpoint] = @s3_endpoint if @s3_endpoint + options[:region] = @s3_region if @s3_region + options[:endpoint] = @s3_endpoint if @s3_endpoint options[:proxy_uri] = @proxy_uri if @proxy_uri options[:use_ssl] = @use_ssl @s3 = AWS::S3.new(options) @bucket = @s3.buckets[@s3_bucket] @@ -114,10 +116,11 @@ @formatter.format(tag, time, record) end def write(chunk) i = 0 + previous_path = nil begin path = @path_slicer.call(@path) values_for_s3_object_key = { "path" => path, @@ -126,10 +129,15 @@ "index" => i } s3path = @s3_object_key_format.gsub(%r(%{[^}]+})) { |expr| values_for_s3_object_key[expr[2...expr.size-1]] } + if (i > 0) && (s3path == previous_path) + raise "duplicated path is generated. use %{index} in s3_object_key_format: path = #{s3path}" + end + i += 1 + previous_path = s3path end while @bucket.objects[s3path].exists? tmp = Tempfile.new("s3-") begin if @store_as == "gzip"