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_HOST
Host where files are served.
Set if files are served from a different host than application.
Defaults to
None
which usesflask.request.host_url
.HASHFS_PATH_PREFIX
URL path prefix where files are served.
Defaults to
''
.HASHFS_ROOT_FOLDER
Root folder to save files.
Must be set.
HASHFS_DEPTH
Number of nested folders to use when saving files.
Defaults to
4
.HASHFS_WIDTH
Width of each nested subfolder.
Defaults to
1
.HASHFS_ALGORITHM
Hashing algorithm to use when computing content hash.
Defaults to
'sha256'
.-
client
¶ Underlying
HashFS
instance.
-
url_for
(relpath, external=True)[source]¶ Return URL for path relative to
HASHFS_ROOT_FOLDER
.Parameters: - relpath (str) – Relative path to
HASHFS_ROOT_FOLDER
where 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
True
after a put operation. Defaults toFalse
.
-