Class: S3Ranger::CLI::Put

Inherits:
CmdParse::Command
  • Object
show all
Defined in:
lib/s3ranger/cli.rb

Instance Method Summary collapse

Constructor Details

#initializePut

Returns a new instance of Put.



193
194
195
196
197
# File 'lib/s3ranger/cli.rb', line 193

def initialize
  super 'put', false, false

  @short_desc = 'Upload a file to a bucket under a certain prefix'
end

Instance Method Details

#run(s3, bucket, key, file, args) ⇒ Object

Raises:



199
200
201
202
203
204
205
# File 'lib/s3ranger/cli.rb', line 199

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