Fix multipart upload failure: raise body limit and fix catch syntax

Axum 0.7 defaults to a 2 MB body limit, which rejects typical phone photos
(often 5–15 MB). Added DefaultBodyLimit::max(50 MB) to accept large images.

Also changed `catch {}` to `catch (e) {}` in the sessionStorage IIFE; the
optional-catch-binding syntax (ES2019) is not supported by all mobile
WebViews, which would have prevented the script from loading entirely.

https://claude.ai/code/session_015myTTMs6yDsAGarATe5ePZ
This commit is contained in:
Claude 2026-03-18 20:47:44 +00:00
parent 0431308cb4
commit 8c5450348a
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,6 @@
use axum::{
body::Body,
extract::{Multipart, Query, State},
extract::{DefaultBodyLimit, Multipart, Query, State},
http::{header, StatusCode},
response::{Html, Json, Response},
routing::{get, post},
@ -65,6 +65,7 @@ async fn main() {
.route("/upload", post(upload))
.route("/download", get(download))
.route("/reset", post(reset_session))
.layer(DefaultBodyLimit::max(50 * 1024 * 1024)) // 50 MB phone photos can be large
.with_state(state);
let addr = "0.0.0.0:3000";

View file

@ -158,7 +158,7 @@
<script>
// Restore coords if iOS discarded the page while camera was open
let gpsCoords = (() => {
try { return JSON.parse(sessionStorage.getItem('gpsCoords')); } catch { return null; }
try { return JSON.parse(sessionStorage.getItem('gpsCoords')); } catch (e) { return null; }
})();
function getLocation() {