class Pipely::S3Writer

Writes content from a String to an S3 path

Public Class Methods

new(s3_path) click to toggle source
# 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

Public Instance Methods

write(content) click to toggle source
# 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