My question is similar in nature to this very helpful answer, but I want to stream in and out simultaneously.
I have a django app that stores references to files on an external http fileserver. Right now when a user requests a zip collection it does the following (pseudo):
generate session_id
for url in url_list:
download file to sessionid/filename.ext
for file in session_id folder:
zip.write
close
http response
Obviously this is less than ideal as it: 1. Requires cleanup, 2. Is slow and 3. causes a long delay before the user sees any download progress.
The bit I'm unable to re-code is the io buffer/"file like object". Zipfile looks for a file on write but I want to provide a stream. In brief, how can I pipe requests
to zipfile
to HttpResponse
?