I have an AWS API Gateway calling a Lambda function (with Proxy integration), which should return an audio file.
Let's say that I have my audio as 'bytes' object. How do I go about returning it, such that it can immediately be recognized and played by the browser (eg Firefox)?
Here's what I got, but, clearly, that doesn't really work.
sound: bytes
return {
'statusCode': 200,
'headers': {
'Content-Type': 'audio/mpeg'
},
'isBase64Encoded': True,
'body': base64.b64encode(sound)
}
base64.b64encode(sound)
in Python) and put the result in 'body'
of your response dictionary. 'isBase64Encoded'
to true in your response dictionary.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.