Skip to content

Commit bc6d1fc

Browse files
change how asset files are returned (#116)
1 parent af1a42b commit bc6d1fc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/django_bird/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import warnings
4+
from io import BytesIO
45

56
from django.conf import settings
67
from django.http import FileResponse
@@ -28,6 +29,6 @@ def asset_view(request: HttpRequest, component_name: str, asset_filename: str):
2829
if not asset or not asset.path.exists():
2930
raise Http404("Asset not found")
3031

31-
file = open(asset.path, "rb")
32+
content = asset.path.read_bytes()
3233

33-
return FileResponse(file, content_type=asset.type.content_type)
34+
return FileResponse(BytesIO(content), content_type=asset.type.content_type)

0 commit comments

Comments
 (0)