mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-14 06:47:00 +10:00
add new feature flag FLAG_DISABLE_IMAGE_PROCESSING
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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" })
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
});
|
||||
|
||||
Vendored
+1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user