Add error message to user if trying to upload too big image

This commit is contained in:
Kalle
2026-01-14 20:59:57 +02:00
parent 2522276be7
commit 41fadb20fe
3 changed files with 49 additions and 5 deletions

View File

@@ -1,5 +1,4 @@
import type { FileUpload } from "@remix-run/form-data-parser";
import { parseFormData as parseMultipartFormData } from "@remix-run/form-data-parser";
import { nanoid } from "nanoid";
import type { ActionFunction } from "react-router";
import { redirect } from "react-router";
@@ -14,6 +13,7 @@ import {
errorToastIfFalsy,
parseFormData,
parseRequestPayload,
safeParseMultipartFormData,
} from "~/utils/remix.server";
import { userArtPage } from "~/utils/urls";
import { NEW_ART_EXISTING_SEARCH_PARAM_KEY } from "../art-constants";
@@ -86,7 +86,7 @@ export const action: ActionFunction = async ({ request }) => {
return null;
};
const formData = await parseMultipartFormData(
const formData = await safeParseMultipartFormData(
request,
// 5MB
{ maxFileSize: 5 * 1024 * 1024 },