You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a TTL serial camera with a board that has no storage, but does have wifi (the M7 metro).
The example code buffers the image from the camera 32 bytes at a time for writing to the SD card. But I was hoping to utilize the Transfer-Enoding: chunked header to send the buffer data with an HTTP request in place of writing to disk.
It doesn't look like the circuitpython requests library supports basic file uploads, let alone a chunked method.
This is a working chunked encoding example that I'm using to test this functionality against a CherryPy server (not shown), which verifies that python-requests can do what it says.
import requests
IMG_FILE = 'image_18000.jpg'
def read_chunks(fileobj, chunk_size=32):
while True:
data = fileobj.read(chunk_size)
if not data:
break
yield data
if __name__ == '__main__':
with open(IMG_FILE, 'rb') as f:
resp = requests.post('http://hb.local:9001', data=read_chunks(f, 32))
print(resp.json())
If I have some time, I will try to create a PR for this functionality.
Basic file uploading is implemented in #189. Contribution of the chunked Transfer-Encoding functionality is welcomed for anyone interested in working on it.
I am using a TTL serial camera with a board that has no storage, but does have wifi (the M7 metro).
The example code buffers the image from the camera 32 bytes at a time for writing to the SD card. But I was hoping to utilize the
Transfer-Enoding: chunked
header to send the buffer data with an HTTP request in place of writing to disk.It doesn't look like the circuitpython requests library supports basic file uploads, let alone a chunked method.
Here is a link to the python-requests docs showing how to do streaming file uploads and chunked body requests: https://requests.readthedocs.io/en/latest/user/advanced/#streaming-uploads
This is a working chunked encoding example that I'm using to test this functionality against a CherryPy server (not shown), which verifies that python-requests can do what it says.
If I have some time, I will try to create a PR for this functionality.
There is also a related issue here: #89
The text was updated successfully, but these errors were encountered: