API Reference¶
The flask-hashfs module.
Flask extension for HashFS, a content-addressable file management system.
-
class
flask_hashfs.FlaskHashFS(app=None)[source]¶ Flask extension for storing files on file system using hashfs.
Configuration values:
HASHFS_HOSTHost where files are served.
Set if files are served from a different host than application.
Defaults to
Nonewhich usesflask.request.host_url.HASHFS_PATH_PREFIXURL path prefix where files are served.
Defaults to
''.HASHFS_ROOT_FOLDERRoot folder to save files.
Must be set.
HASHFS_DEPTHNumber of nested folders to use when saving files.
Defaults to
4.HASHFS_WIDTHWidth of each nested subfolder.
Defaults to
1.HASHFS_ALGORITHMHashing algorithm to use when computing content hash.
Defaults to
'sha256'.-
client¶ Underlying
HashFSinstance.
-
url_for(relpath, external=True)[source]¶ Return URL for path relative to
HASHFS_ROOT_FOLDER.Parameters: - relpath (str) – Relative path to
HASHFS_ROOT_FOLDERwhere file is located. - external (bool) – Whether to include host in URL.
Returns: URL for path.
Return type: str
Note
This function builds the URL with the assumption that relpath is a valid file path. It does not check for file existence.
- relpath (str) – Relative path to
-
-
class
flask_hashfs.HashAddress[source]¶ File address containing file’s path on disk and it’s content hash ID.
-
id¶ str – Hash ID (hexdigest) of file contents.
-
relpath¶ str – Relative path location to
HashFS.root.
-
abspath¶ str – Absoluate path location of file on disk.
-
is_duplicate¶ boolean, optional – Whether the hash address created was a duplicate of a previously existing file. Can only be
Trueafter a put operation. Defaults toFalse.
-