Raise mobile upload limits

This commit is contained in:
vance 2026-04-09 22:53:14 -07:00
parent 08c9cc4efb
commit d90f8bd645
3 changed files with 16 additions and 3 deletions

View File

@ -21,6 +21,12 @@ export const createSubmission = async (
onProgress?: (progress: number) => void
): Promise<CreateSubmissionResponse> =>
new Promise((resolve, reject) => {
const maxUploadBytes = 64 * 1024 * 1024;
if (input.file.size > maxUploadBytes) {
reject(new Error("That image is too large for the current upload limit. Please choose a smaller photo."));
return;
}
const formData = new FormData();
formData.append("file", input.file);
formData.append("displayName", input.displayName ?? "");
@ -48,7 +54,13 @@ export const createSubmission = async (
return;
}
reject(new Error((request.response as { message?: string } | null)?.message ?? "Upload failed."));
const responseMessage = (request.response as { message?: string } | null)?.message;
if (request.status === 413) {
reject(new Error("That image is too large for the current upload limit. Please choose a smaller photo."));
return;
}
reject(new Error(responseMessage ?? `Upload failed (${request.status || "network"}).`));
});
request.addEventListener("error", () => {

View File

@ -1,6 +1,7 @@
server {
listen 80;
server_name _;
client_max_body_size 64m;
root /usr/share/nginx/html;
index index.html;

View File

@ -214,7 +214,7 @@ const createSubmissionFromMultipart = async (
export const buildServer = async () => {
const app = Fastify({
logger: true,
bodyLimit: 25 * 1024 * 1024
bodyLimit: 64 * 1024 * 1024
});
const store = new StateStore(config.stateFile);
@ -265,7 +265,7 @@ export const buildServer = async () => {
await app.register(multipart, {
limits: {
files: 1,
fileSize: 25 * 1024 * 1024
fileSize: 64 * 1024 * 1024
}
});
await app.register(fastifyStatic, {