Skip to content

Instantly share code, notes, and snippets.

@Feawel
Created February 11, 2017 16:56
Show Gist options
  • Save Feawel/197959518f60c29f81646254ed152814 to your computer and use it in GitHub Desktop.
Save Feawel/197959518f60c29f81646254ed152814 to your computer and use it in GitHub Desktop.
const writeAudioStreamToS3 = ( audioStream, filename ) =>
putObject(aws_publicBucket, filename, audioStream,'audio/mp3').then( res => {
if(!res.ETag) throw res
else return {
msg: 'File successfully generated.',
ETag: res.ETag,
url: `https://s3-eu-west-1.amazonaws.com/${aws_publicBucket}/${filename}`
}
})
const putObject = (bucket, key, body, ContentType) =>
s3.putObject({
Bucket: bucket,
Key: key,
Body: body,
ContentType
}).promise()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment