Use file.chunks() on large cached files

This commit is contained in:
Raphael Michel
2018-06-02 12:16:44 +02:00
parent 11ff81f852
commit 7fb3d13733
2 changed files with 12 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
from django.http import StreamingHttpResponse
class ChunkBasedFileResponse(StreamingHttpResponse):
block_size = 4096
def __init__(self, streaming_content=(), *args, **kwargs):
streaming_content = streaming_content.chunks(self.block_size)
super().__init__(streaming_content, *args, **kwargs)