Upload object from a file


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 = s3.create_bucket("bucket_name") ①
key = bucket.new_key('amazon.jpg') ②
testfile = "amazon.jpg" ③
fp = open(testfile,'rb') ④
key.set_contents_from_file(fp) ⑤
key.delete() ⑥
bucket.delete() ⑦

① Create a Vault called bucket_name.
② Create an Object called amazon.jpg.
③ Set the test file to the amazon.jpg file.
④ Open the amazon.jpg.
⑤ Write the contents of the amazon.jpg file to the Object in the Vault.
⑥ Delete the Object.
⑦ Delete the bucket_name Vault.