Class: Configuration::S3Store
- Inherits:
-
S3SourceStoreBase
- Object
- Scope
- HandlerStatement
- SourceStoreBase
- S3SourceStoreBase
- Configuration::S3Store
- Includes:
- PerfStats
- 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
Methods inherited from Scope
#initialize, node_parsers, #parse, register_node_parser
Constructor Details
This class inherits a constructor from Configuration::S3SourceStoreBase
Class Method Details
.match(node) ⇒ Object
427 428 429 |
# File 'lib/httpimagestore/configuration/s3.rb', line 427 def self.match(node) node.name == 'store_s3' end |
.parse(configuration, node) ⇒ Object
431 432 433 |
# File 'lib/httpimagestore/configuration/s3.rb', line 431 def self.parse(configuration, node) configuration.stores << super end |
Instance Method Details
#realize(request_state) ⇒ Object
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/httpimagestore/configuration/s3.rb', line 435 def realize(request_state) get_named_image_for_storage(request_state) do |image_name, image, rendered_path| acl = @public_access ? :public_read : :private log.info "storing '#{image_name}' image in S3 '#{@bucket}' bucket under '#{rendered_path}' key with #{acl} access" measure "storing image in S3", "image: '#{image_name}' bucket: '#{@bucket}'" do object(rendered_path) do |object| image.mime_type or log.warn "storing '#{image_name}' in S3 '#{@bucket}' bucket under '#{rendered_path}' key with unknown mime type" = {} [:single_request] = true [:content_type] = image.mime_type if image.mime_type [:acl] = acl [:cache_control] = @cache_control if @cache_control object.write(image.data, ) S3SourceStoreBase.stats.incr_total_s3_store S3SourceStoreBase.stats.incr_total_s3_store_bytes(image.data.bytesize) image.store_url = url(object) end end end end |