Class: Wukong::EmrCommand::S3Util
- Defined in:
- lib/wukong/script/emr_command.rb
Overview
Simple class to coordinate s3 operations
Class Method Summary collapse
Class Method Details
.bucket_and_path_from_uri(uri) ⇒ Object
152 153 154 |
# File 'lib/wukong/script/emr_command.rb', line 152 def bucket_and_path_from_uri uri uri =~ %r{^s3\w*://([\w\.\-]+)\W*(.*)} and return([$1, $2]) end |
.s3 ⇒ Object
147 148 149 150 151 |
# File 'lib/wukong/script/emr_command.rb', line 147 def s3 @s3 ||= RightAws::S3Interface.new( Settings.access_key, Settings.secret_access_key, {:multi_thread => true, :logger => Log, :port => 80, :protocol => 'http' }) end |
.store(filename, uri) ⇒ Object
155 156 157 158 159 160 |
# File 'lib/wukong/script/emr_command.rb', line 155 def store filename, uri dest_bucket, dest_key = bucket_and_path_from_uri(uri) Log.debug " #{filename} => #{dest_bucket} / #{dest_key}" contents = File.read(filename) s3.store_object(:bucket => dest_bucket, :key => dest_key, :data => contents) end |