fix(upload): detect unnamed multipart files
Build and Push Docker Container / build-and-push (push) Successful in 1m38s

- Treat an existing multipart file field as upload content even when FileStorage has an empty filename.

- Keep upload telemetry aligned with file field presence instead of FileStorage truthiness.

- Add regression coverage for frontend-style uploads that provide a file field without a filename.

- Bump NanoShare to 1.27.2 and refresh the staged lockfile.
This commit is contained in:
2026-09-09 23:42:30 +02:00
parent 74ecc9b4b6
commit 21aca1b9d7
4 changed files with 192 additions and 45 deletions
+6 -4
View File
@@ -74,19 +74,21 @@ async def api_upload(user):
text = form.get('text', '')
orphan_registry = getattr(current_app, 'orphan_storage_registry', None)
add_wide_event_context(nanoshare={"operation": "upload", "has_file": bool(files.get('file')), "has_text": bool(text.strip())})
uploaded = files.get('file')
has_uploaded_file = uploaded is not None
add_wide_event_context(nanoshare={"operation": "upload", "has_file": has_uploaded_file, "has_text": bool(text.strip())})
expires_at_dt = ensure_utc(parse_expires(expires_raw))
if not uploaded and not text.strip():
if not has_uploaded_file and not text.strip():
add_wide_event_context(nanoshare={"operation_status": "missing_content"})
return jsonify({'ok': False, 'error': 'No content provided'}), 400
content_type = None
# --- binary upload path ---
if uploaded:
if has_uploaded_file:
fname = uploaded.filename or ''
add_wide_event_context(nanoshare={"upload_type": "file", "filename_present": bool(fname)})
ctype = uploaded.mimetype or 'application/octet-stream'