class CarthageCacheRes::AWSRepository

Attributes

bucket_name[R]
client[R]

Public Class Methods

new(bucket_name, client_options = {}) click to toggle source
# File lib/carthage_cache_res/repository.rb, line 10
def initialize(bucket_name, client_options = {})
  @client = ::Aws::S3::Client.new(client_options)
  @bucket_name = bucket_name
end

Public Instance Methods

archive_exist?(archive_filename) click to toggle source
# File lib/carthage_cache_res/repository.rb, line 15
def archive_exist?(archive_filename)
  ::Aws::S3::Object.new(bucket_name, archive_filename, client: client).exists?
end
download(archive_filename, destination_path) click to toggle source
# File lib/carthage_cache_res/repository.rb, line 19
def download(archive_filename, destination_path)
  resp = client.get_object(
    response_target: destination_path,
    bucket: bucket_name,
    key: archive_filename)
end
upload(archive_filename, archive_path) click to toggle source
# File lib/carthage_cache_res/repository.rb, line 26
def upload(archive_filename, archive_path)
  File.open(archive_path, 'rb') do |file|
    client.put_object(bucket: bucket_name, key: archive_filename, body: file)
  end
end