add new feature flag FLAG_DISABLE_IMAGE_PROCESSING

This commit is contained in:
Amruth Pillai
2026-02-10 18:33:07 +01:00
parent f237c42093
commit 87e2f2f391
9 changed files with 25 additions and 7 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ export const storageRouter = {
},
})
.handler(async ({ context, input }): Promise<void> => {
// The filename is now the full path from the URL (e.g., "uploads/userId/pictures/timestamp.webp")
// The filename is now the full path from the URL (e.g., "uploads/userId/pictures/timestamp.ext")
// We need to extract just the path portion that matches the storage key
const key = input.filename.startsWith("uploads/")
? input.filename
+10 -1
View File
@@ -7,7 +7,6 @@ import {
PutObjectCommand,
S3Client,
} from "@aws-sdk/client-s3";
import sharp from "sharp";
import { env } from "@/utils/env";
interface StorageWriteInput {
@@ -90,6 +89,16 @@ interface ProcessedImage {
export async function processImageForUpload(file: File): Promise<ProcessedImage> {
const fileBuffer = await file.arrayBuffer();
console.log("FLAG_DISABLE_IMAGE_PROCESSING", env.FLAG_DISABLE_IMAGE_PROCESSING);
if (env.FLAG_DISABLE_IMAGE_PROCESSING) {
return {
data: new Uint8Array(fileBuffer),
contentType: file.type,
};
}
const sharp = (await import("sharp")).default;
const processedBuffer = await sharp(fileBuffer)
.resize(800, 800, { fit: "inside", withoutEnlargement: true })
.webp({ preset: "picture" })
+1
View File
@@ -67,5 +67,6 @@ export const env = createEnv({
FLAG_DEBUG_PRINTER: z.stringbool().default(false),
FLAG_DISABLE_SIGNUPS: z.stringbool().default(false),
FLAG_DISABLE_EMAIL_AUTH: z.stringbool().default(false),
FLAG_DISABLE_IMAGE_PROCESSING: z.stringbool().default(false),
},
});
+1
View File
@@ -52,5 +52,6 @@ declare namespace NodeJS {
FLAG_DEBUG_PRINTER: string | boolean;
FLAG_DISABLE_SIGNUPS: string | boolean;
FLAG_DISABLE_EMAIL_AUTH: string | boolean;
FLAG_DISABLE_IMAGE_PROCESSING: string | boolean;
}
}