I want to upload upload base64 encoded image to lambda function from postman.
{
"name": "vendor"
"image": "base64-enoceded"
}
Lambda Function
try:
data = json.loads(event['body'])
name = data['name']
image = data['image']
image = base64.b64decode(data['image'])
cdn_object = CDNConnector('bunny_cdn_api_key','assets')
cdn_object.upload_file('vendor-assets/', image)
return {
'statusCode': 200,
"body": json.dumps("File uploaded")
}
except Exception as e:
return {
"statusCode":200,
"body": str(e)
}
But I got this error 'embedded null byte' when I show the file after decoded string, It shows class bytes. But the I want the actual file after decoding i.e. images.png after decoding that I will upload to CDN because CDN required file not bytes.