oioioi.filetracker.utils

Module Contents

Classes

FileInFiletracker

A stub django.core.files.File subclass for assigning existing

Functions

django_to_filetracker_path(django_file)

Returns the filetracker path of a django.core.files.File.

filetracker_to_django_file(filetracker_path[, storage])

Returns a File representing an existing

make_content_disposition_header(disposition, filename)

Returns a Content-Disposition header field per RFC 6266

stream_file(django_file[, name, showable])

Returns a HttpResponse representing a file download.

class oioioi.filetracker.utils.FileInFiletracker(storage, name)[source]

Bases: django.core.files.File

A stub 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')
size()[source]
close()[source]
oioioi.filetracker.utils.django_to_filetracker_path(django_file)[source]

Returns the filetracker path of a django.core.files.File.

oioioi.filetracker.utils.filetracker_to_django_file(filetracker_path, storage=None)[source]

Returns a File representing an existing Filetracker file (usable only for assigning to a FileField)

oioioi.filetracker.utils.make_content_disposition_header(disposition, filename)[source]

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.

oioioi.filetracker.utils.stream_file(django_file, name=None, showable=None)[source]

Returns a 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.