I have a Django app that needs to interact with a database of medical images. They have a RESTful API that returns a stream of bytes, which I am writing to a HttpStreamingResponse. This is working, but the issue is that it is very slow. Most files I am downloading are around 100mb, and it usually takes around 15-20 seconds before the download even begins. Does anyone have insight into how to speed up this process and start the download faster?
Here is my code:
# Make api call
response = requests.get(url, cookies=dict(JSESSIONID=self.session_id))
# write bytes to Http Response
http = StreamingHttpResponse(io.BytesIO(response.content), content_type='application/zip')
http['Content-Disposition'] = 'attachment; filename="%s.zip"' % patient_id
return http