Class: S3Cmd::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/s3cmd.rb

Instance Method Summary collapse

Instance Method Details

#create_bucket(name) ⇒ Object



23
24
25
# File 'lib/s3cmd.rb', line 23

def create_bucket(name)
  s3.bucket(name, true)
end

#get(bucket, key) ⇒ Object



33
34
35
# File 'lib/s3cmd.rb', line 33

def get(bucket, key)
  puts s3.bucket(bucket).get(key)
end

#list_bucketsObject



17
18
19
# File 'lib/s3cmd.rb', line 17

def list_buckets
  puts s3.buckets
end

#list_keys(bucket) ⇒ Object



28
29
30
# File 'lib/s3cmd.rb', line 28

def list_keys(bucket)
  puts s3.bucket(bucket).keys
end

#put(bucket, key, file) ⇒ Object



39
40
41
42
43
# File 'lib/s3cmd.rb', line 39

def put(bucket, key, file)
  bucket = s3.bucket(bucket)
  type = options[:type] || MIME::Types.of(file).first.to_s
  File.open(file, "r") { |f| bucket.put(key, f, {}, nil, { "content-type" => type }) }
end