coderuday21 Cursor commited on
Commit
995884c
·
1 Parent(s): 79b0691

Raise library image upload limit to 15 GB

Browse files

Increase 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 CHANGED
@@ -10,8 +10,9 @@
10
  # Local image library folder (default: library_sources/)
11
  # LOCAL_LIBRARY_ROOT=C:/path/to/your/images
12
 
13
- # GeoTIFF upload limit in MB (default 5120 = 5 GB)
14
- # MAX_GEOTIFF_MB=5120
 
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=5120
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
- # GeoTIFF library upload limit (default 5 GB; override with MAX_GEOTIFF_MB on HF dev Space)
87
- MAX_GEOTIFF_BYTES = int(os.environ.get("MAX_GEOTIFF_MB", "5120")) * 1024 * 1024
 
88
 
89
- # Raster sidecar formats (PNG/JPEG) smaller cap for library uploads
90
- MAX_IMAGE_BYTES = int(os.environ.get("MAX_IMAGE_MB", "50")) * 1024 * 1024
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 GeoTIFF.`;
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 maxBytes = window.ddaState?.localCfg?.maxGeotiffBytes
31
- || (window.ddaState?.localCfg?.maxGeotiffMb || 5120) * 1024 * 1024;
 
 
 
 
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=9"></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>
 
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>