In fact, you just need to put the name of the subcategory and / in front of the file name. The following code snippet will place a file called 'test.jpg' . k.make_public() makes this file publicly available, but not necessarily by the bucket itself.
from boto.s3.connection import S3Connection from boto.s3.key import Key connection = S3Connection(AWSKEY,AWS_SECRET_KEY) bucket = connection.get_bucket('MyBucket') file = 'test.jpg' k = Key(bucket) k.key = 'MySubBucket/' + file k.set_contents_from_filename(file) k.make_public()
source share