Replies: 2 comments
-
This is a client-side problem. XMLHttpRequest is probably the way to go.
This can be addressed with standard synchronization primitives. If you want to support only one upload at a time you can use a |
Beta Was this translation helpful? Give feedback.
-
Thank you for your advice. To clarify, this is what you have in the example # write the file to the files directory in 1K chunks
with open('files/' + filename, 'wb') as f:
while size > 0:
chunk = await request.stream.read(min(size, 1024))
f.write(chunk)
size -= len(chunk) I see a problem if the request is canceled from the client side. In my case, the stream keeps reading zero chunks. # write the file to the files directory in 1K chunks
with open(folder + "/" + filename, "wb") as f:
fail = 0
while size > 0:
chunk = await request.stream.read(min(size, 1024))
f.write(chunk)
size -= len(chunk)
# no new chunk coming in, user hanged up
if len(chunk) == 0:
fail += 1
if fail > 10:
break
print(f"processed {size}")
if fail > 10:
print(f"removing {folder}/{filename}")
os.remove(folder + "/" + filename)
return {"error": "user hanged up"}, 414 I have memory issues on the esp32 devkit 1. I don't have memory issues on the ESP32 S3. |
Beta Was this translation helpful? Give feedback.
-
Thank you for microdot and the upload example.
I have two questions:
I just checked and my modification does now work.
Fetch does not support upload progress, as such XMLHttpRequest is often suggested.
If I sent multiple request to the upload button, microdot runs out of memory.
--> Memory issues are caused by #198 and have been solved
.
Beta Was this translation helpful? Give feedback.
All reactions