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
- #directory ⇒ Object
-
#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
#directory ⇒ Object
14 15 16 17 18 |
# File 'lib/pipely/s3_writer.rb', line 14 def directory directory = storage.directories.detect{ |d| d.key == @host } directory or raise("Couldn't find S3 bucket '#{@host}'") end |
#write(content) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/pipely/s3_writer.rb', line 20 def write(content) remote_file = directory.files.create({ :key => @path, :body => content, :public => true, }) remote_file.public_url end |