My goal is to do a PUT of part of a file using requests and stream the file (i.e., not load it into memory and then do the PUT).
This page explains how you would do that for an entire file:
Requests supports streaming uploads, which allow you to send large streams or files without reading them into memory. To stream and upload, simply provide a file-like object for your body:
with open('massive-body', 'rb') as f:
requests.post('http://some.url/streamed', data=f)
However in my case I want to only send one chunk of the file. Is there a way to accomplish this?
In concept, something like:
with open('massive-body', 'rb') as f:
requests.post('http://some.url/streamed', data=f.read(chunksize))