I need to post a file using request module in python, which has unicode characters in filename.
I am using below code:
url = "https://demo.php"
headers = {'Accept': 'application/vnd.ve.v1.0+json','API': 'aasadadas'}
file_up = {'filename': open(file_name, 'rb')}
upload_file_rest =requests.post(url,files=file_up,headers=headers,verify=False)
Using the above code and when passing the filename as "指事字.exe", I am getting below exception:
'ascii' codec can't decode byte 0xc2 in position 26: ordinal not in range(128)
Any help is really appreciated.
PS: I had already tried below code, and it doesn't worked for me:
file_up = {'filename': open(file_name.encode('utf-8'), 'rb')}