Skip to content

Instantly share code, notes, and snippets.

@frivas
Created May 2, 2019 16:29
Show Gist options
  • Save frivas/66ec4f9b63334438b58803d4a38e4656 to your computer and use it in GitHub Desktop.
Save frivas/66ec4f9b63334438b58803d4a38e4656 to your computer and use it in GitHub Desktop.
Get S3 Audio URL
def getS3AudioFile():
s3_filename = hashlib.md5(open('/tmp/output.mp3', 'rb').read()).hexdigest() + '.mp3'
s3.Bucket(bucket_name).upload_file(Filename='/tmp/output.mp3', Key=s3_filename, ExtraArgs={'ACL':'public-read'})
os.remove('/tmp/sound.mp3')
os.remove('/tmp/output.mp3')
return f'<audio src="{s3_url}{bucket_name}/{s3_filename}"/>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment