mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
20 lines
629 B
Python
20 lines
629 B
Python
"""Stream files from storage."""
|
|
|
|
from django.core.files.storage import DefaultStorage
|
|
|
|
from django_downloadview.files import StorageFile
|
|
from django_downloadview.views.path import PathDownloadView
|
|
|
|
|
|
class StorageDownloadView(PathDownloadView):
|
|
"""Serve a file using storage and filename."""
|
|
|
|
#: Storage the file to serve belongs to.
|
|
storage = DefaultStorage()
|
|
|
|
#: Path to the file to serve relative to storage.
|
|
path = None # Override docstring.
|
|
|
|
def get_file(self):
|
|
"""Return :class:`~django_downloadview.files.StorageFile` instance."""
|
|
return StorageFile(self.storage, self.get_path())
|