Skip to content

Instantly share code, notes, and snippets.

@ghawkgu
Created May 31, 2011 10:13
Show Gist options
  • Save ghawkgu/1000263 to your computer and use it in GitHub Desktop.
Save ghawkgu/1000263 to your computer and use it in GitHub Desktop.
Writing into s3 with boto.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from boto.s3.connection import S3Connection
from boto.s3.key import Key
conn = S3Connection('access key', 'access secret')
bucket = conn.get_bucket('some-bucket')
# Write into 'mysql/test.txt'
k = Key(bucket)
k.key = 'mysql/test.txt'
k.set_contents_from_string('Test message.')
# How to load the content from a local file and then writing into s3
# k.set_contents_from_file(open('/home/xxx/test.txt'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment