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



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

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

.parse(configuration, node) ⇒ Object



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

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

Instance Method Details

#realize(request_state) ⇒ Object



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

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