diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-22 16:46:02 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-22 16:46:02 -0700 |
| commit | 3311bc27f52dc00b9226deb7e683754fa4c8316b (patch) | |
| tree | a90d6fcc9899c5c20d55d2ad92b8bdb2daafc891 /lib/S3Cli/__init__.py | |
| parent | d3e7b5708deffbed864c916de22663f48333c58b (diff) | |
ok finishing server
Diffstat (limited to 'lib/S3Cli/__init__.py')
| -rw-r--r-- | lib/S3Cli/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/S3Cli/__init__.py b/lib/S3Cli/__init__.py new file mode 100644 index 0000000..70ba24c --- /dev/null +++ b/lib/S3Cli/__init__.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) |
