Module: S3Handler
- Defined in:
- lib/easys3/s3_handler.rb
Class Method Summary collapse
- .file_exists?(bucket, file_name) ⇒ Boolean
- .get_bucket(bucket_name, ignore_keys = false) ⇒ Object
- .get_s3_resorce(ignore_keys = false) ⇒ Object
Class Method Details
.file_exists?(bucket, file_name) ⇒ Boolean
32 33 34 |
# File 'lib/easys3/s3_handler.rb', line 32 def self.file_exists?(bucket, file_name) return bucket.object(file_name).exists? end |
.get_bucket(bucket_name, ignore_keys = false) ⇒ Object
26 27 28 29 30 |
# File 'lib/easys3/s3_handler.rb', line 26 def self.get_bucket(bucket_name, ignore_keys=false) ErrorHandler.check_aws_region() s3 = S3Handler.get_s3_resorce(ignore_keys) return s3.bucket(bucket_name) end |
.get_s3_resorce(ignore_keys = false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/easys3/s3_handler.rb', line 6 def self.get_s3_resorce(ignore_keys=false) ErrorHandler.check_aws_region() if ignore_keys return Aws::S3::Resource.new( region: ENV["AWS_S3_REGION"], ) end ErrorHandler.check_aws_access_key() ErrorHandler.check_aws_secret_access_key() return Aws::S3::Resource.new( region: ENV["AWS_S3_REGION"], access_key_id: ENV["AWS_ACCESS_KEY_ID"], secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"], ) end |