loboris / MicroPython_ESP32_psRAM_LoBo

MicroPython for ESP32 with psRAM support
Other
831 stars 344 forks source link

how to post files to remote server? #324

Open thugbobby opened 4 years ago

thugbobby commented 4 years ago

Hello. I want to post some files to remote server.But I have not found how to post. In python, I can post file like this:

import requests
payload = {}
files = [
  ('uploads2', open('/D:/cat.png','rb')),
]
headers= {}
response = requests.request("POST", url, headers=headers, data = payload, files = files)
print(response.text.encode('utf8'))

but in micropython, what should I do? the urequests doesn`t have parameter files.

Thanks for your help!

k4m454k commented 4 years ago

Look here https://github.com/jono-allen/MQTT-Cam/blob/master/uploader.py