예제 #1
0
파일: botox.py 프로젝트: umairghani/templar
 def get_contents(self, bucket, key):
   """Get value from S3 bucket """
   try:
     __bucket__ = self.conn.get_bucket(bucket)
     __k__ = Key(__bucket__)
     __k__.key = key
     return __k__.get_contents_from_string()
   except Exception, e:
     raise BotoxException(e)
예제 #2
0
def fetch_s3_file(s3path):
    """ Fetch a file from S3 - Function cached """
    _file_uploads_enabled()  # Make sure image uploads are enabled

    conn = boto.connect_s3(app.config["BUCKETEER_AWS_ACCESS_KEY_ID"],
                           app.config["BUCKETEER_AWS_SECRET_ACCESS_KEY"])
    b = conn.get_bucket(app.config["BUCKETEER_BUCKET_NAME"])

    # TODO: Wrap in try/except to raise FileNotFoundError when file doesn't exist
    sml = Key(b)
    sml.key = s3path
    return sml.get_contents_from_string()