diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:27:27 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:27:27 -0700 |
| commit | 5c982ed500b51f5b8d911e5a5adec10ac2d31d2e (patch) | |
| tree | efca7a0f0209d25972df00173e4c92a814956a7a /lib/S3Cli.py | |
| parent | 2755b029d873f93d91086b3d69a4c57d05c40fb5 (diff) | |
ok good
Diffstat (limited to 'lib/S3Cli.py')
| -rw-r--r-- | lib/S3Cli.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/S3Cli.py b/lib/S3Cli.py new file mode 100644 index 0000000..70ba24c --- /dev/null +++ b/lib/S3Cli.py @@ -0,0 +1,24 @@ +from config import * +import sys +from boto.s3.connection import S3Connection +from boto.s3.key import Key +class S3Cli(object): + def __init__(self): + try: + self.conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, is_secure=False) + self.bucket = self.conn.get_bucket(BUCKET_NAME) + except Exception as e: + sys.stderr.write("Could not connect to s3\n"); + sys.stderr.write(str(e)) + sys.exit(1) + + def s3move(self, filename,objectname): + try: + k = Key(self.bucket) + k.key = objectname + k.set_contents_from_filename(filename) + k.set_acl('public-read') + k.storage_class = 'REDUCED_REDUNDANCY' + except Exception as e: + sys.stderr.write(str(e)); + sys.exit(1) |
