| 1 |
"""Stream files from storage.""" |
| 2 |
|
| 3 |
from django.core.files.storage import DefaultStorage |
| 4 |
|
| 5 |
from django_downloadview.files import StorageFile |
| 6 |
from django_downloadview.views.path import PathDownloadView |
| 7 |
|
| 8 |
|
| 9 |
class StorageDownloadView(PathDownloadView): |
| 10 |
"""Serve a file using storage and filename.""" |
| 11 |
|
| 12 |
#: Storage the file to serve belongs to. |
| 13 |
storage = DefaultStorage() |
| 14 |
|
| 15 |
#: Path to the file to serve relative to storage. |
| 16 |
path = None # Override docstring. |
| 17 |
|
| 18 |
def get_file(self): |
| 19 |
"""Return :class:`~django_downloadview.files.StorageFile` instance.""" |
| 20 |
return StorageFile(self.storage, self.get_path()) |