Class: Pipely::S3Writer
- Inherits:
-
Object
- Object
- Pipely::S3Writer
- Defined in:
- lib/pipely/s3_writer.rb
Overview
Writes content from a String to an S3 path
Instance Method Summary collapse
-
#initialize(s3_path) ⇒ S3Writer
constructor
A new instance of S3Writer.
- #write(content) ⇒ Object
Constructor Details
#initialize(s3_path) ⇒ S3Writer
Returns a new instance of S3Writer.
9 10 11 12 |
# File 'lib/pipely/s3_writer.rb', line 9 def initialize(s3_path) uri = URI.parse(s3_path) @host, @path = uri.host, uri.path.gsub(/^\//,'') end |
Instance Method Details
#write(content) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/pipely/s3_writer.rb', line 14 def write(content) s3_bucket = Aws::S3::Bucket.new(@host) s3_object = s3_bucket.object(@path) s3_object.put(body: content, acl: 'public') s3_object.public_url end |