← index #6310Issue #232
Off-topic · high · value 0.828
QUERY · ISSUE

how to use urequests to post files?

openby thugbobbyopened 2020-08-05updated 2024-08-27

I want to post some files to remote server.But I found that the urequests.post() doesn`t have parameter files.

this is in python:

import requests

payload = {}
files = [
  ('uploads2', open('/D:/cat.png','rb')),
  ('uploads1', open('/D:/tecsun/456.jpg','rb'))
]
headers= {}

response = requests.request("POST", url, headers=headers, data = payload, files = files)

print(response.text.encode('utf8'))

how to use this in micropython? thank you !

CANDIDATE · ISSUE

urequests induces esp8266 crash with a message LmacRxBlk:1

closedby disassemblyopened 2017-11-08updated 2017-11-08

I am using micropython on an esp8266 board, when I use urequests to post data to 2 different servers, after serval loops, esp8266 crashes with this message LmacRxBlk:1, need to hard reset the board to make it work again.
The code is like this:
while True:
r1 = urequests.post(SOME_URL,headers=xxx,data=xxxx)
r2= urequests.post(SOME_URL_1,headers=xxxx,data=xxxx)
time.sleep(300)
But if I post data to only 1 server, it never comes to the crash LmacRxBlk:1.
Does anybody know why?

1 comment
pfalcon · 2017-11-08

Please read the docs: http://docs.micropython.org/en/latest/esp8266/esp8266/general.html#sockets-and-wifi-buffers-overflow

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied