Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Flask extension for HashFS, a content-addressable file management system.

Project Description

Flask extension for HashFS, a content-addressable file management system.

What is HashFS?

HashFS is a content-addressable file management system. What does that mean? Simply, that HashFS manages a directory where files are saved based on the file’s hash.

Typical use cases for this kind of system are ones where:

  • Files are written once and never change (e.g. image storage).
  • It’s desirable to have no duplicate files (e.g. user uploads).
  • File metadata is stored elsewhere (e.g. in a database).

What is Flask-HashFS?

Flask-HashFS is a Flask extension that integrates HashFS into the Flask ecosystem.


Install using pip:

pip install Flask-HashFS


from flask import Flask
from flask_hashfs import FlaskHashFS

app = Flask(__name__)
fs = FlaskHashFS()

Configure Flask-HashFS to store files in /var/www/data/uploads and give them a route prefix at /uploads.

    'HASHFS_HOST': None,
    'HASHFS_PATH_PREFIX': '/uploads',
    'HASHFS_ROOT_FOLDER': '/var/www/data/uploads',
    'HASHFS_DEPTH': 4,
    'HASHFS_WIDTH': 1,
    'HASHFS_ALGORITHM': 'sha256'



Use Flask-HashFS to manage files using HashFS.

with app.app_context():
    # Store readable objects or file paths
    address = fs.put(io_obj, extension='.jpg')

    # Get a file's hash address
    assert fs.get( == address
    assert fs.get(address.relpath) == address
    assert fs.get(address.abspath) == address
    assert fs.get('invalid') is None

    # Get a BufferedReader handler
    fileio =

    # Or using the full path...
    fileio =

    # Or using a path relative to fs.root
    fileio =

    # Delete a file by address ID or path

For direct access to the HashFS instance, use the client attribute.

assert isinstance(fs.client, flask_hashfs.HashFS)

Generate URLs for HashFS content.

with app.test_request_context():

For more details, please see the full documentation at and


v0.3.0 (2015-06-03)

  • Replace manual proxy access of HashFS methods with single __getattr__ method.

v0.2.0 (2015-06-02)

  • Pin hashfs dependency to >=0.3.0. (breaking change)
  • Rename config key HASHFS_LENGTH to HASHFS_WIDTH to be in alignment with hashfs>=0.3.0. (breaking change)

v0.1.0 (2015-06-02)

  • First release.
  • Add FlaskHashFS.put.
  • Add FlaskHashFS.get.
  • Add
  • Add FlaskHashFS.delete.
  • Add FlaskHashFS.url_for.
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Flask_HashFS-0.3.0-py2.py3-none-any.whl (7.6 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jun 3, 2015
Flask-HashFS-0.3.0.tar.gz (16.0 kB) Copy SHA256 Checksum SHA256 Source Jun 3, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting