fix: stabilize generated ZIP download for large archives
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

Avoid HTTP/2 streaming failures on large archive downloads by returning the stored ZIP as a buffered HttpResponse with explicit Content-Length.

Also update archive download tests to support both buffered and streaming response objects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mariomitte
2026-08-06 11:17:15 +02:00
parent 456c9e4c3e
commit 18c65a6f84
2 changed files with 10 additions and 3 deletions

View File

@@ -351,7 +351,7 @@ class WorkOrderImagesEndpointTests(TestCase):
download_response = self.client.get(f"/api/fleet/reports/generated-archives/{generated.pk}/download/")
self.assertEqual(download_response.status_code, 200)
self.assertEqual(download_response['Content-Type'], 'application/zip')
archive_bytes = b''.join(download_response.streaming_content)
archive_bytes = download_response.content if hasattr(download_response, 'content') else b''.join(download_response.streaming_content)
archive = zipfile.ZipFile(BytesIO(archive_bytes))
self.assertIn('MT150726.SN-Test_servisni_zadatak.docx', archive.namelist())
@@ -392,7 +392,7 @@ class WorkOrderImagesEndpointTests(TestCase):
download_response = self.client.get(f"/api/fleet/reports/generated-archives/{generated.pk}/download/")
self.assertEqual(download_response.status_code, 200)
self.assertEqual(download_response['Content-Type'], 'application/zip')
archive_bytes = b''.join(download_response.streaming_content)
archive_bytes = download_response.content if hasattr(download_response, 'content') else b''.join(download_response.streaming_content)
archive = zipfile.ZipFile(BytesIO(archive_bytes))
names = archive.namelist()