Last active
November 19, 2021 19:03
-
-
Save tuergeist/c111d6b784136608745195e08078bd4f to your computer and use it in GitHub Desktop.
Event handle for multipart form data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handler_name(event, context): | |
try: | |
result = '' | |
content_type_header = event['headers']['content-type'] | |
post_data = base64.b64decode(event['body']).decode('iso-8859-1') | |
for part in decoder.MultipartDecoder( | |
post_data.encode('utf-8'), | |
content_type_header | |
).parts: | |
result = reverse_it(part.text.split('\n')) | |
result = '\n'.join(result) | |
return result | |
except Exception as e: | |
print('error occured', e) | |
print('# event') | |
print(event) | |
return { | |
"statusCode": 500, | |
"body": "could not handle error, see log", | |
"headers": { | |
'Content-Type': 'text/html', | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment