Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

decode multipart/form-data python lambda

import cgi
import io

def handler(event, context):
    print(event)
    print(event['body'])

    fp = io.BytesIO(event['body'].encode('utf-8'))
    pdict = cgi.parse_header(event['headers']['Content-Type'])[1]
    if 'boundary' in pdict:
        pdict['boundary'] = pdict['boundary'].encode('utf-8')
    pdict['CONTENT-LENGTH'] = len(event['body'])
    form_data = cgi.parse_multipart(fp, pdict)
    print('form_data=', form_data)
Comment

PREVIOUS NEXT
Code Example
Python :: pandas dataframe add two columns int and string 
Python :: reading the JSON from a JSON file 
Python :: renpy 
Python :: how to use for loop to take n number of input in python 
Python :: decode utf8 whit python 
Python :: python enum to int 
Python :: defaultdict initialize keys 
Python :: Splitting strings in Python without split() 
Python :: how to plot kmeans centroids 
Python :: python add item to list 
Python :: get all different element of both list python 
Python :: matplotlib draw line x1, y1 
Python :: numpy set nan to 0 
Python :: np matrix drop zero column 
Python :: how to find index of maximum value in dataframe in python 
Python :: python matrix 
Python :: python logistic function 
Python :: NumPy resize Example 
Python :: python compute cross product 
Python :: how to use def in python 
Python :: mount gdrive in pyton 
Python :: indexing python first and last 
Python :: numpy array divide each row by its sum 
Python :: sort a dict by values 
Python :: python replace one character into string 
Python :: datetime columns only extract date pandas 
Python :: df split into train, validation, test 
Python :: imagefield django models 
Python :: Word2Vec 4.0 Gensim model python dataframe 
Python :: django abstractuser 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =