Sha256: 7ff5b2c30276c68ed8cd197a9d27169345b454b50423015ba9bacf45a1beee40
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require "aws-sdk" require "time" module Reustyle REGION = 'eu-west-1' BUCKET = 'uswitch-assets-eu' CLOUDFRONT_DISTRIBUTION = 'E3F1XI0HIG20E0' ONE_YEAR_IN_S = 1 * 365 * 24 * 60 * 60 ONE_YEAR_FROM_NOW = Time.now + ONE_YEAR_IN_S def self.s3_upload to, from, content_type, bucket = BUCKET bucket = s3.bucket(bucket) object = bucket.object(to) object.put( body: open(from), content_type: content_type, acl: 'public-read', cache_control: "max-age=#{ONE_YEAR_IN_S}, public", expires: ONE_YEAR_FROM_NOW.httpdate ) end def self.invalidate files cloudfront = Aws::CloudFront::Client.new(region: REGION) cloudfront.create_invalidation( distribution_id: CLOUDFRONT_DISTRIBUTION, invalidation_batch: { paths: { quantity: files.length, items: files }, caller_reference: "ustyle invalidation at #{Time.now.to_s}" } ) end def self.s3 @conn ||= Aws::S3::Resource.new(region: REGION) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reustyle-2.0.10 | lib/ustyle/deploy.rb |