hls-segmenter_1.py 719 B

1234567891011121314151617
  1. def s3_file_upload(config, filename, keyname):
  2. conn = S3Connection(config['aws']["access_key"], config['aws']["secret_key"])
  3. mybucket = conn.get_bucket(config['aws']["s3bucket"]) # select bucket
  4. k = Key(mybucket) # select key
  5. k.key = keyname # named new key
  6. k.set_contents_from_filename(filename) # upload new file name
  7. k.set_acl('public-read') # set publis read access
  8. keylist = mybucket.list() # get list of files
  9. result = False
  10. ss = []
  11. for key in keylist:
  12. ss.append(key.name)
  13. if any(keyname in s for s in ss):
  14. logging.debug('s3_file_upload ' + 'Upload ' + keyname + "Completed")
  15. result = result | True
  16. rs = conn.close()
  17. return result