Is there any way to stream file from remote URL with Django Response (without downloading the file locally)?
# view.py
def file_recover(request, *args, **kwargs):
file_url = "http://remote-file-storage.com/file/111"
return StreamFileFromURLResponse(file_url)
We have file storage (files can be large - 1 GB and more). We can't share download url (there are security issues). File streaming can significantly increase download speed by forwarding download stream to Django response.
Django has built in StreamingHttpResponse class which should be given an iterator that yields strings as content. In example below I'm using
requests
Raw Response Content