fastlane/lib/fastlane/helper/s3_client_helper.rb in fastlane-2.145.0 vs fastlane/lib/fastlane/helper/s3_client_helper.rb in fastlane-2.146.0
- old
+ new
@@ -5,20 +5,18 @@
class S3ClientHelper
attr_reader :client
def initialize(access_key: nil, secret_access_key: nil, region: nil)
creds = Aws::Credentials.new(access_key, secret_access_key)
- Aws.config.update({
+ Aws.config.update(
region: region,
credentials: creds
- })
-
- @client = Aws::S3::Client.new
+ )
end
def list_buckets
- return @client.list_buckets
+ return client.list_buckets
end
def upload_file(bucket_name, file_name, file_data, acl)
bucket = find_bucket!(bucket_name)
details = {
@@ -38,19 +36,26 @@
# Return public url
obj.public_url.to_s
end
- def delete_file(bucket, file_name)
+ def delete_file(bucket_name, file_name)
bucket = find_bucket!(bucket_name)
- bucket.objects[file_name].delete
+ file = bucket.object(file_name)
+ file.delete
end
def find_bucket!(bucket_name)
- bucket = Aws::S3::Bucket.new(bucket_name, client: @client)
+ bucket = Aws::S3::Bucket.new(bucket_name, client: client)
raise "Bucket '#{bucket_name}' not found" unless bucket.exists?
return bucket
end
+ end
+
+ private
+
+ def client
+ @client ||= Aws::S3::Client.new
end
end
end