Class: S3Sync::CLI::Put
- Defined in:
- lib/s3sync/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ Put
constructor
A new instance of Put.
- #run(s3, bucket, key, file, args) ⇒ Object
- #usage ⇒ Object
Methods inherited from BaseCmd
#execute, #has_options?, #has_prefix?
Constructor Details
#initialize ⇒ Put
Returns a new instance of Put.
307 308 309 310 311 312 |
# File 'lib/s3sync/cli.rb', line 307 def initialize super 'put', takes_commands: 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
318 319 320 321 322 323 324 |
# File 'lib/s3sync/cli.rb', line 318 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 = S3Sync.safe_join [key, File.basename(file)] s3.bucket(bucket).object(name).upload_file(Pathname.new(file)) end |
#usage ⇒ Object
314 315 316 |
# File 'lib/s3sync/cli.rb', line 314 def usage "#{super} path/to/local/destination" end |