1234567891011121314151617 |
- def s3_file_upload(config, filename, keyname):
- conn = S3Connection(config['aws']["access_key"], config['aws']["secret_key"])
- mybucket = conn.get_bucket(config['aws']["s3bucket"]) # select bucket
- k = Key(mybucket) # select key
- k.key = keyname # named new key
- k.set_contents_from_filename(filename) # upload new file name
- k.set_acl('public-read') # set publis read access
- keylist = mybucket.list() # get list of files
- result = False
- ss = []
- for key in keylist:
- ss.append(key.name)
- if any(keyname in s for s in ss):
- logging.debug('s3_file_upload ' + 'Upload ' + keyname + "Completed")
- result = result | True
- rs = conn.close()
- return result
|