Class: ActiveAdmin::AsyncExporter::Services::AwsS3Service
- Inherits:
-
Object
- Object
- ActiveAdmin::AsyncExporter::Services::AwsS3Service
- Defined in:
- lib/active_admin/async_exporter/services/aws_s3_service.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#file ⇒ Object
Returns the value of attribute file.
-
#object ⇒ Object
Returns the value of attribute object.
-
#s3 ⇒ Object
Returns the value of attribute s3.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(file) ⇒ AwsS3Service
constructor
A new instance of AwsS3Service.
- #store ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(file) ⇒ AwsS3Service
Returns a new instance of AwsS3Service.
9 10 11 12 13 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 9 def initialize(file) @file = file @s3 = Aws::S3::Resource.new @bucket = s3.bucket(ActiveAdmin::AsyncExporter.config.aws_bucket_name) end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
7 8 9 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 7 def bucket @bucket end |
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 7 def file @file end |
#object ⇒ Object
Returns the value of attribute object.
7 8 9 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 7 def object @object end |
#s3 ⇒ Object
Returns the value of attribute s3.
7 8 9 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 7 def s3 @s3 end |
Instance Method Details
#delete ⇒ Object
25 26 27 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 25 def delete bucket.delete_objects({ delete: { objects: [{ key: filename }] } }) end |
#store ⇒ Object
15 16 17 18 19 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 15 def store @object = bucket.object(filename) object.upload_file(Pathname.new(file[:path]), { acl: 'public-read' }) self end |
#url ⇒ Object
21 22 23 |
# File 'lib/active_admin/async_exporter/services/aws_s3_service.rb', line 21 def url object.public_url.to_s end |