@chrishamm There is and I successfully do it by passing an iterator as "data" to POST request, it feeds the request with chunks of data. Everything is fine but it is a blocking IO. I'm trying to make it async, ond one of the ways is to pass chunks sequentially in subsequent POST requests, only RRF treats each chunk as a separate file.
I have to dig into it more and perhaps make an async iterator and use it with async uploader, which I failed to do as of yet.
This is a working non async upload code:
import requests
class upload_in_chunks(object):
def __init__(self, filename, chunksize=1 << 13):
self.filename = filename
self.chunksize = chunksize
self.totalsize = os.path.getsize(filename)
self.readsofar = 0
def __iter__(self):
with open(self.filename, 'rb') as file:
while True:
data = file.read(self.chunksize)
if not data:
sys.stderr.write("\n")
break
self.readsofar += len(data)
percent = self.readsofar * 1e2 / self.totalsize
sys.stderr.write("\r{percent:3.0f}%".format(percent=percent))
yield data
def __len__(self):
return self.totalsize
def sendme():
requests.get(baseurl+'/rr_connect?password=reprap')
requests.post(url, data=upload_in_chunks(afile, chunksize=10))