-
-
Notifications
You must be signed in to change notification settings - Fork 813
Closed
Labels
Description
I can do this by modifying this function:
datasette/datasette/utils/asgi.py
Lines 248 to 270 in 02dc629
| async def asgi_send_file( | |
| send, filepath, filename=None, content_type=None, chunk_size=4096 | |
| ): | |
| headers = {} | |
| if filename: | |
| headers["Content-Disposition"] = 'attachment; filename="{}"'.format(filename) | |
| first = True | |
| async with aiofiles.open(str(filepath), mode="rb") as fp: | |
| if first: | |
| await asgi_start( | |
| send, | |
| 200, | |
| headers, | |
| content_type or guess_type(str(filepath))[0] or "text/plain", | |
| ) | |
| first = False | |
| more_body = True | |
| while more_body: | |
| chunk = await fp.read(chunk_size) | |
| more_body = len(chunk) == chunk_size | |
| await send( | |
| {"type": "http.response.body", "body": chunk, "more_body": more_body} | |
| ) |
Reactions are currently unavailable