OpenQuizz
Une application de gestion des contenus pédagogiques
FileStorage Class Reference
Inheritance diagram for FileStorage:
Collaboration diagram for FileStorage:

Public Member Functions

def __init__ (self, stream=None, filename=None, name=None, content_type=None, content_length=None, headers=None)
 
def content_type (self)
 
def content_length (self)
 
def mimetype (self)
 
def mimetype_params (self)
 
def save (self, dst, buffer_size=16384)
 
def close (self)
 
def __nonzero__ (self)
 
def __getattr__ (self, name)
 
def __iter__ (self)
 
def __repr__ (self)
 

Data Fields

 name
 
 stream
 
 filename
 
 headers
 

Detailed Description

The :class:`FileStorage` class is a thin wrapper over incoming files.
It is used by the request object to represent uploaded files.  All the
attributes of the wrapper stream are proxied by the file storage so
it's possible to do ``storage.read()`` instead of the long form
``storage.stream.read()``.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  stream = None,
  filename = None,
  name = None,
  content_type = None,
  content_length = None,
  headers = None 
)

Member Function Documentation

◆ __getattr__()

def __getattr__ (   self,
  name 
)

◆ __iter__()

def __iter__ (   self)

◆ __nonzero__()

def __nonzero__ (   self)

◆ __repr__()

def __repr__ (   self)

◆ close()

def close (   self)
Close the underlying file if possible.

◆ content_length()

def content_length (   self)
The content-length sent in the header.  Usually not available

◆ content_type()

def content_type (   self)
The content-type sent in the header.  Usually not available

◆ mimetype()

def mimetype (   self)
Like :attr:`content_type`, but without parameters (eg, without
charset, type etc.) and always lowercase.  For example if the content
type is ``text/HTML; charset=utf-8`` the mimetype would be
``'text/html'``.

.. versionadded:: 0.7

◆ mimetype_params()

def mimetype_params (   self)
The mimetype parameters as dict.  For example if the content
type is ``text/html; charset=utf-8`` the params would be
``{'charset': 'utf-8'}``.

.. versionadded:: 0.7

◆ save()

def save (   self,
  dst,
  buffer_size = 16384 
)
Save the file to a destination path or file object.  If the
destination is a file object you have to close it yourself after the
call.  The buffer size is the number of bytes held in memory during
the copy process.  It defaults to 16KB.

For secure file saving also have a look at :func:`secure_filename`.

:param dst: a filename, :class:`os.PathLike`, or open file
    object to write to.
:param buffer_size: Passed as the ``length`` parameter of
    :func:`shutil.copyfileobj`.

.. versionchanged:: 1.0
    Supports :mod:`pathlib`.

Field Documentation

◆ filename

filename

◆ headers

headers

◆ name

name

◆ stream

stream

The documentation for this class was generated from the following file: