Copy object


import boto
import time
import sys
import logging
import boto.s3.connection
import ConfigParser

host = '192.168.9.230'

s3 = boto.connect_s3(
  host = host,
  is_secure = false,
  calling_format = boto.s3.connection.OrdinaryCallingFormat(),
  )

bucket_source = s3.create_bucket(str(sys.argv[1])) 1
bucket_dest = s3.create_bucket(str(sys.argv[2])) 2

i = 0; 3
while i < 50: 4
  key = bucket_source.new_key('test ' + str(i)) 5
  key.set_contents_from_string("KeyCreateTest!") 6  
  i = i + 1 7

for key in bucket_source.list(): 8
print "Copy {name}\t{size}\t{modified} to bucket\t{bucket}".format(
name = key.name,
size = key.size,
modified = key.last_modified,
bucket = str(sys.argv[2])
) 9
key.copy(bucket_dest,key) 10

1 Create a Source Vault called the name given as the first variable passed to this 
  method was.
2 Create a Destination Vault called the name given as the second variable passed to 
  this method was.
3 Create an iteration variable and set its value to 0.
4 While the iteration variable value is less than 50…
5 Create an Object called test{iterationVariable}.
6 Write KeyCreateTest! into the contents of this Object.
7 Increment the iteration variable by 1.
8 While there are Objects in the list of Source Objects…
9 Display Copy {objectSize} {Date Modified} to bucket {vaultName}
10 Copy this Object to the Destination Vault.