:py:mod:`oioioi.filetracker.utils` ================================== .. py:module:: oioioi.filetracker.utils Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.filetracker.utils.FileInFiletracker Functions ~~~~~~~~~ .. autoapisummary:: oioioi.filetracker.utils.django_to_filetracker_path oioioi.filetracker.utils.filetracker_to_django_file oioioi.filetracker.utils.make_content_disposition_header oioioi.filetracker.utils.stream_file .. py:class:: FileInFiletracker(storage, name) Bases: :py:obj:`django.core.files.File` A stub :class:`django.core.files.File` subclass for assigning existing Filetracker files to :class:`django.db.models.FileField`s. Usage:: some_model_instance.file_field = filetracker_to_django_file('some/path') .. py:method:: size() .. py:method:: close() .. py:function:: django_to_filetracker_path(django_file) Returns the filetracker path of a :class:`django.core.files.File`. .. py:function:: filetracker_to_django_file(filetracker_path, storage=None) Returns a :class:`~django.core.files.File` representing an existing Filetracker file (usable only for assigning to a :class:`~django.db.models.FileField`) .. py:function:: make_content_disposition_header(disposition, filename) Returns a Content-Disposition header field per RFC 6266 as a bytestring. The ``disposition`` argument should be either ``inline`` or ``attachment`` and the filename should be a unicode object, which need not be sanitized. .. py:function:: stream_file(django_file, name=None, showable=None) Returns a :class:`HttpResponse` representing a file download. Optional argument ``name`` sets default filename under which user is prompted to save that ``django_file``. Some types of files, as listed below in ``showable_exts`` variable, may by default be displayed in browser. Other are forced to be downloaded. Using ``showable`` flag, default behaviour may be overriden in both directions.