Skip to content

Commit

Permalink
Configurable upload size (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
Repumba committed Mar 14, 2023
1 parent 3b42e3c commit 4a4abba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/setup-and-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ Plugin settings:
Storage settings:


* ``max_upload_size`` (integer) - Maximum upload size in bytes. Keep in mind that this value refers to whole upload request (``Content-Length`` from request header), so the maximum file size is smaller than that by +/- 500B (because of additional payload with metadata). Default is ``None``, which means there is no limit.
* ``storage_provider`` (disk or s3) - If you want to use S3-compatible object storage instead of local file system, set this option to ``s3``. Default is ``disk``.
* ``hash_pathing`` (0 or 1) - Should we break up the uploads into different folders. If you use S3-compatible storage, recommended option is ``0`` (default: ``1``).
* ``s3_storage_endpoint`` (string) - S3 API endpoint for object storage. Required if you use S3-compatible storage.
Expand Down
2 changes: 2 additions & 0 deletions mwdb/core/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from flask import Blueprint, Flask

from mwdb.core.config import app_config
from mwdb.core.rate_limit import limiter

from .service import Service

app = Flask(__name__, static_folder=None)
app.config["MAX_CONTENT_LENGTH"] = app_config.mwdb.max_upload_size
api_blueprint = Blueprint("api", __name__, url_prefix="/api")
api = Service(app, api_blueprint)
app.register_blueprint(api_blueprint)
Expand Down
4 changes: 4 additions & 0 deletions mwdb/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class MWDBConfig(Config):
)
# File upload timeout
file_upload_timeout = key(cast=int, required=False, default=60000)
# Maximum upload size, default is None (no limit)
# This value refers to whole upload request ('Content-Length' from request header)
# Maximum file size is smaller than that by +/- 500 B
max_upload_size = key(cast=int, required=False, default=None)
# Folder for uploads
uploads_folder = key(cast=path, required=False)
# Should we break up the uploads into different folders for example:
Expand Down

0 comments on commit 4a4abba

Please sign in to comment.