Sha256: d790c250daea8db082e50ab5570723f57d14d194dc974d97f84603e9a44838dc

Contents?: true

Size: 794 Bytes

Versions: 16

Compression:

Stored size: 794 Bytes

Contents

require "aws-sdk"

module Ustyle
  REGION = 'eu-west-1'
  BUCKET = 'uswitch-assets-eu'
  CLOUDFRONT_DISTRIBUTION = 'E3F1XI0HIG20E0'

  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')
  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

16 entries across 16 versions & 1 rubygems

Version Path
ustyle-1.14.0 lib/ustyle/deploy.rb
ustyle-1.12.6 lib/ustyle/deploy.rb
ustyle-1.12.1 lib/ustyle/deploy.rb
ustyle-1.12.0 lib/ustyle/deploy.rb
ustyle-1.11.1 lib/ustyle/deploy.rb
ustyle-1.10.0 lib/ustyle/deploy.rb
ustyle-1.8.7 lib/ustyle/deploy.rb
ustyle-1.8.1 lib/ustyle/deploy.rb
ustyle-1.8.0 lib/ustyle/deploy.rb
ustyle-1.7.0 lib/ustyle/deploy.rb
ustyle-1.6.1 lib/ustyle/deploy.rb
ustyle-1.5.8 lib/ustyle/deploy.rb
ustyle-1.4.1 lib/ustyle/deploy.rb
ustyle-1.4.0 lib/ustyle/deploy.rb
ustyle-1.3.12 lib/ustyle/deploy.rb
ustyle-1.3.6 lib/ustyle/deploy.rb