Spaces:
Sleeping
Sleeping
Commit ·
995884c
1
Parent(s): 79b0691
Raise library image upload limit to 15 GB
Browse filesIncrease default MAX_GEOTIFF_MB and MAX_IMAGE_MB to 15360 so GeoTIFF,
PNG, and JPEG uploads share a 15 GB cap on dev and in the Docker image.
Co-authored-by: Cursor <cursoragent@cursor.com>
- .env.example +3 -2
- Dockerfile +1 -1
- app/dda/config.py +5 -4
- app/dda/library_routes.py +1 -0
- app/dda/local_routes.py +3 -0
- static/js/dda/app.js +1 -1
- static/js/dda/library.js +6 -2
- templates/index_dda.html +1 -1
.env.example
CHANGED
|
@@ -10,8 +10,9 @@
|
|
| 10 |
# Local image library folder (default: library_sources/)
|
| 11 |
# LOCAL_LIBRARY_ROOT=C:/path/to/your/images
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
# MAX_GEOTIFF_MB=
|
|
|
|
| 15 |
|
| 16 |
# Max pixel dimension for detection (lower = less RAM, default 4096 local)
|
| 17 |
# DETECTION_MAX_SIDE=4096
|
|
|
|
| 10 |
# Local image library folder (default: library_sources/)
|
| 11 |
# LOCAL_LIBRARY_ROOT=C:/path/to/your/images
|
| 12 |
|
| 13 |
+
# Image upload limit in MB (default 15360 = 15 GB)
|
| 14 |
+
# MAX_GEOTIFF_MB=15360
|
| 15 |
+
# MAX_IMAGE_MB=15360
|
| 16 |
|
| 17 |
# Max pixel dimension for detection (lower = less RAM, default 4096 local)
|
| 18 |
# DETECTION_MAX_SIDE=4096
|
Dockerfile
CHANGED
|
@@ -22,7 +22,7 @@ WORKDIR /app
|
|
| 22 |
# Build-time info + cache-bust:
|
| 23 |
# Changing APP_BUILD forces Docker to re-run subsequent layers (including pip install).
|
| 24 |
ARG APP_BUILD=37
|
| 25 |
-
ENV MAX_GEOTIFF_MB=
|
| 26 |
ENV APP_BUILD=${APP_BUILD}
|
| 27 |
ENV GDAL_CONFIG=/usr/bin/gdal-config
|
| 28 |
RUN echo "Docker build start: APP_BUILD=${APP_BUILD}" && python -V
|
|
|
|
| 22 |
# Build-time info + cache-bust:
|
| 23 |
# Changing APP_BUILD forces Docker to re-run subsequent layers (including pip install).
|
| 24 |
ARG APP_BUILD=37
|
| 25 |
+
ENV MAX_GEOTIFF_MB=15360
|
| 26 |
ENV APP_BUILD=${APP_BUILD}
|
| 27 |
ENV GDAL_CONFIG=/usr/bin/gdal-config
|
| 28 |
RUN echo "Docker build start: APP_BUILD=${APP_BUILD}" && python -V
|
app/dda/config.py
CHANGED
|
@@ -83,11 +83,12 @@ THUMBS_DIR = LIBRARY_DIR / "thumbs"
|
|
| 83 |
PREVIEWS_DIR = LIBRARY_DIR / "previews"
|
| 84 |
LOCAL_THUMB_CACHE = DATA_DIR / "library_cache" / "thumbs"
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
-
#
|
| 90 |
-
MAX_IMAGE_BYTES = int(os.environ.get("MAX_IMAGE_MB",
|
| 91 |
|
| 92 |
ALLOWED_EXTENSIONS = {".tif", ".tiff", ".png", ".jpg", ".jpeg"}
|
| 93 |
|
|
|
|
| 83 |
PREVIEWS_DIR = LIBRARY_DIR / "previews"
|
| 84 |
LOCAL_THUMB_CACHE = DATA_DIR / "library_cache" / "thumbs"
|
| 85 |
|
| 86 |
+
# Library upload limit (default 15 GB; override with MAX_GEOTIFF_MB / MAX_IMAGE_MB)
|
| 87 |
+
_MAX_UPLOAD_MB_DEFAULT = "15360" # 15 * 1024
|
| 88 |
+
MAX_GEOTIFF_BYTES = int(os.environ.get("MAX_GEOTIFF_MB", _MAX_UPLOAD_MB_DEFAULT)) * 1024 * 1024
|
| 89 |
|
| 90 |
+
# PNG/JPEG use the same cap unless MAX_IMAGE_MB is set separately
|
| 91 |
+
MAX_IMAGE_BYTES = int(os.environ.get("MAX_IMAGE_MB", _MAX_UPLOAD_MB_DEFAULT)) * 1024 * 1024
|
| 92 |
|
| 93 |
ALLOWED_EXTENSIONS = {".tif", ".tiff", ".png", ".jpg", ".jpeg"}
|
| 94 |
|
app/dda/library_routes.py
CHANGED
|
@@ -75,6 +75,7 @@ def dda_config():
|
|
| 75 |
"maxGeotiffMb": MAX_GEOTIFF_BYTES // (1024 * 1024),
|
| 76 |
"maxGeotiffBytes": MAX_GEOTIFF_BYTES,
|
| 77 |
"maxImageMb": MAX_IMAGE_BYTES // (1024 * 1024),
|
|
|
|
| 78 |
"geotiffEnabled": geotiff_io_available(),
|
| 79 |
"allowedExtensions": sorted(ALLOWED_EXTENSIONS),
|
| 80 |
"hierarchyMode": "tree",
|
|
|
|
| 75 |
"maxGeotiffMb": MAX_GEOTIFF_BYTES // (1024 * 1024),
|
| 76 |
"maxGeotiffBytes": MAX_GEOTIFF_BYTES,
|
| 77 |
"maxImageMb": MAX_IMAGE_BYTES // (1024 * 1024),
|
| 78 |
+
"maxImageBytes": MAX_IMAGE_BYTES,
|
| 79 |
"geotiffEnabled": geotiff_io_available(),
|
| 80 |
"allowedExtensions": sorted(ALLOWED_EXTENSIONS),
|
| 81 |
"hierarchyMode": "tree",
|
app/dda/local_routes.py
CHANGED
|
@@ -17,6 +17,7 @@ from .geotiff_io import load_rgb_pil
|
|
| 17 |
from .config import (
|
| 18 |
IS_DDA_MODE,
|
| 19 |
MAX_GEOTIFF_BYTES,
|
|
|
|
| 20 |
geotiff_io_available,
|
| 21 |
get_detection_max_side,
|
| 22 |
get_library_roots,
|
|
@@ -73,6 +74,8 @@ def local_library_config():
|
|
| 73 |
"detectionMaxSide": get_detection_max_side(),
|
| 74 |
"maxGeotiffMb": MAX_GEOTIFF_BYTES // (1024 * 1024),
|
| 75 |
"maxGeotiffBytes": MAX_GEOTIFF_BYTES,
|
|
|
|
|
|
|
| 76 |
"maxUploadGb": round(MAX_GEOTIFF_BYTES / (1024 ** 3), 2),
|
| 77 |
}
|
| 78 |
|
|
|
|
| 17 |
from .config import (
|
| 18 |
IS_DDA_MODE,
|
| 19 |
MAX_GEOTIFF_BYTES,
|
| 20 |
+
MAX_IMAGE_BYTES,
|
| 21 |
geotiff_io_available,
|
| 22 |
get_detection_max_side,
|
| 23 |
get_library_roots,
|
|
|
|
| 74 |
"detectionMaxSide": get_detection_max_side(),
|
| 75 |
"maxGeotiffMb": MAX_GEOTIFF_BYTES // (1024 * 1024),
|
| 76 |
"maxGeotiffBytes": MAX_GEOTIFF_BYTES,
|
| 77 |
+
"maxImageMb": MAX_IMAGE_BYTES // (1024 * 1024),
|
| 78 |
+
"maxImageBytes": MAX_IMAGE_BYTES,
|
| 79 |
"maxUploadGb": round(MAX_GEOTIFF_BYTES / (1024 ** 3), 2),
|
| 80 |
}
|
| 81 |
|
static/js/dda/app.js
CHANGED
|
@@ -132,7 +132,7 @@ async function initDda() {
|
|
| 132 |
|
| 133 |
const uploadLimit = document.getElementById('upload-limit-hint');
|
| 134 |
if (uploadLimit && localCfg.maxUploadGb) {
|
| 135 |
-
uploadLimit.textContent = `Select a tree node and image type. Max ${localCfg.maxUploadGb} GB per
|
| 136 |
}
|
| 137 |
|
| 138 |
const resHint = document.getElementById('dda-detect-res-hint');
|
|
|
|
| 132 |
|
| 133 |
const uploadLimit = document.getElementById('upload-limit-hint');
|
| 134 |
if (uploadLimit && localCfg.maxUploadGb) {
|
| 135 |
+
uploadLimit.textContent = `Select a tree node and image type. Max ${localCfg.maxUploadGb} GB per file.`;
|
| 136 |
}
|
| 137 |
|
| 138 |
const resHint = document.getElementById('dda-detect-res-hint');
|
static/js/dda/library.js
CHANGED
|
@@ -27,8 +27,12 @@ document.getElementById('form-tree-upload')?.addEventListener('submit', async (e
|
|
| 27 |
if (!nodeId) return showDdaError?.('Select a tree node.');
|
| 28 |
if (!file) return showDdaError?.('Select a file.');
|
| 29 |
|
| 30 |
-
const
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if (file.size > maxBytes) {
|
| 33 |
return showDdaError?.(`File is ${formatBytes(file.size)} — max ${formatBytes(maxBytes)}.`);
|
| 34 |
}
|
|
|
|
| 27 |
if (!nodeId) return showDdaError?.('Select a tree node.');
|
| 28 |
if (!file) return showDdaError?.('Select a file.');
|
| 29 |
|
| 30 |
+
const ext = (file.name.split('.').pop() || '').toLowerCase();
|
| 31 |
+
const isTiff = ext === 'tif' || ext === 'tiff';
|
| 32 |
+
const cfg = window.ddaState?.localCfg || {};
|
| 33 |
+
const maxBytes = isTiff
|
| 34 |
+
? (cfg.maxGeotiffBytes || (cfg.maxGeotiffMb || 15360) * 1024 * 1024)
|
| 35 |
+
: (cfg.maxImageBytes || (cfg.maxImageMb || 15360) * 1024 * 1024);
|
| 36 |
if (file.size > maxBytes) {
|
| 37 |
return showDdaError?.(`File is ${formatBytes(file.size)} — max ${formatBytes(maxBytes)}.`);
|
| 38 |
}
|
templates/index_dda.html
CHANGED
|
@@ -324,7 +324,7 @@
|
|
| 324 |
|
| 325 |
<script src="/static/js/dda/app.js?v=15"></script>
|
| 326 |
<script src="/static/js/dda/tree.js?v=2"></script>
|
| 327 |
-
<script src="/static/js/dda/library.js?v=
|
| 328 |
<script src="/static/js/dda/result.js?v=7"></script>
|
| 329 |
<script src="/static/js/dda/compare.js?v=11"></script>
|
| 330 |
<script src="/static/js/dda/reports.js?v=4"></script>
|
|
|
|
| 324 |
|
| 325 |
<script src="/static/js/dda/app.js?v=15"></script>
|
| 326 |
<script src="/static/js/dda/tree.js?v=2"></script>
|
| 327 |
+
<script src="/static/js/dda/library.js?v=10"></script>
|
| 328 |
<script src="/static/js/dda/result.js?v=7"></script>
|
| 329 |
<script src="/static/js/dda/compare.js?v=11"></script>
|
| 330 |
<script src="/static/js/dda/reports.js?v=4"></script>
|