Class: S3Ranger::CLI::Put
- Defined in:
- lib/s3ranger/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ Put
constructor
A new instance of Put.
- #run(s3, bucket, key, file, args) ⇒ Object
Methods inherited from BaseCmd
#has_options?, #has_prefix?, #usage
Constructor Details
#initialize ⇒ Put
Returns a new instance of Put.
276 277 278 279 280 281 |
# File 'lib/s3ranger/cli.rb', line 276 def initialize super 'put', false, false @short_desc = 'Upload a file to a bucket under a certain prefix' @has_prefix = true end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/s3ranger/cli.rb', line 283 def run s3, bucket, key, file, args raise WrongUsage.new(nil, "You need to inform a bucket") if not bucket raise WrongUsage.new(nil, "You need to inform a file") if not file name = S3Ranger.safe_join [key, File.basename(file)] s3.buckets[bucket].objects[name].write Pathname.new(file) end |