Class: Configuration::S3Source

Inherits:
S3SourceStoreBase show all
Defined in:
lib/httpimagestore/configuration/s3.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from S3SourceStoreBase

#client, #initialize, #object, #url

Methods inherited from SourceStoreBase

#initialize

Methods included from ConditionalInclusion

#excluded?, #included?, #inclusion_matcher

Constructor Details

This class inherits a constructor from Configuration::S3SourceStoreBase

Class Method Details

.match(node) ⇒ Object



374
375
376
# File 'lib/httpimagestore/configuration/s3.rb', line 374

def self.match(node)
	node.name == 'source_s3'
end

.parse(configuration, node) ⇒ Object



378
379
380
# File 'lib/httpimagestore/configuration/s3.rb', line 378

def self.parse(configuration, node)
	configuration.sources << super
end

Instance Method Details

#realize(request_state) ⇒ Object



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/httpimagestore/configuration/s3.rb', line 382

def realize(request_state)
	put_sourced_named_image(request_state) do |image_name, rendered_path|
		log.info "sourcing '#{image_name}' image from S3 '#{@bucket}' bucket under '#{rendered_path}' key"

		object(rendered_path) do |object|
			data = request_state.memory_limit.get do |limit|
				object.read(limit + 1)
			end
			S3SourceStoreBase.stats.incr_total_s3_source
			S3SourceStoreBase.stats.incr_total_s3_source_bytes(data.bytesize)

			image = Image.new(data, object.content_type)
			image.source_url = url(object)
			image
		end
	end
end

#to_sObject



400
401
402
# File 'lib/httpimagestore/configuration/s3.rb', line 400

def to_s
	"S3Source[image_name: '#{@image_name}' bucket: '#{@bucket}' prefix: '#{@prefix}' path_spec: '#{@path_spec}']"
end