mirror of
https://github.com/django/django.git
synced 2024-11-25 07:59:34 +01:00
16 lines
367 B
Python
16 lines
367 B
Python
|
from io import BytesIO
|
||
|
|
||
|
from django.http import FileResponse
|
||
|
|
||
|
FILE_RESPONSE_HOLDER = {}
|
||
|
|
||
|
|
||
|
def file_response(request):
|
||
|
f1 = BytesIO(b"test1")
|
||
|
f2 = BytesIO(b"test2")
|
||
|
response = FileResponse(f1)
|
||
|
response._resource_closers.append(f2.close)
|
||
|
FILE_RESPONSE_HOLDER["response"] = response
|
||
|
FILE_RESPONSE_HOLDER["buffers"] = (f1, f2)
|
||
|
return response
|