I use Django to stream direct a file from a URL and return it directly to the client. But when user cancel download file, the Django view is never end and it was hang. Does anyone know any keyword or solution for this issue. Please help.
This is my django code.
def stream_media(request, download_url):
response = requests.get(url=download_url, stream=True)
response = StreamingHttpResponse((chunk for chunk in response.iter_content(chunk_size=2048)))
response = add_content_disposition_header(response=response, filename=filename)
return response