Get a storage by its name

flask_fs.init_app(app, *storages)[source]

Initialize Storages configuration Register blueprint if necessary.

  • app – The ~flask.Flask instance to get the configuration from.
  • storages – A Storage instance list to register and configure.

File types

This module handle image operations (thumbnailing, resizing...)

flask_fs.images.make_thumbnail(file, size, bbox=None)[source]

Generate a thumbnail for a given image file.

  • file (file) – The source image file to thumbnail
  • size (int) – The thumbnail size in pixels (Thumbnails are squares)
  • bbox (tuple) – An optionnal Bounding box definition for the thumbnail


class flask_fs.backends.BaseBackend(name, config)[source]

Abstract class to implement backend.

as_binary(content, encoding=u'utf8')[source]

Perform content encoding for binary write


Delete a file given its filename in the storage


Test wether a file exists or not given its filename in the storage

open(filename, *args, **kwargs)[source]

Open a file given its filename relative to the storage root


Read a file content given its filename in the storage

save(file_or_wfs, filename, overwrite=False)[source]

Save a file-like object or a werkzeug.FileStorage with the specified filename.

  • storage – The file or the storage to be saved.
  • filename – The destination in the storage.
  • overwrite – if False, raise an exception if file exists in storage

FileExists – when file exists and overwrite is False


Serve a file given its filename

write(filename, content)[source]

Write content into a file given its filename in the storage



These are all errors used accross this extensions.

exception flask_fs.errors.FSError[source]

Base class for all Flask-FS Exceptions

exception flask_fs.errors.FileExists[source]

Raised when trying to overwrite an existing file

exception flask_fs.errors.FileNotFound[source]

Raised when trying to access a non existant file

exception flask_fs.errors.UnauthorizedFileType[source]

This exception is raised when trying to upload an unauthorized file type.

exception flask_fs.errors.UploadNotAllowed[source]

Raised when trying to upload into storage where upload is not allowed.

exception flask_fs.errors.OperationNotSupported[source]

Raised when trying to perform an operation not supported by the current backend


These are internal classes or helpers. Most of the time you shouldn’t have to deal directly with them.