Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Fix crash when accessing page with image upload component on self-hosted (#2129)
Luke Vellab69214103cc0
diff --git a/apps/web/src/components/image-upload/image-upload.tsx b/apps/web/src/components/image-upload/image-upload.tsxindex ea8c78722..e833bef4c 100644--- a/apps/web/src/components/image-upload/image-upload.tsx+++ b/apps/web/src/components/image-upload/image-upload.tsx@@ -20,7 +20,7 @@ import {} from "@/lib/image-processing";import { useSafeAction } from "@/lib/safe-action/client";import { getImageUploadUrlAction } from "@/lib/storage/actions";-import { uploadImage } from "@/lib/storage/image-upload";+import { uploadImage } from "@/lib/storage/upload-client";export function ImageUpload({ className, children }: ImageUploadProps) {return (diff --git a/apps/web/src/lib/storage/image-upload.ts b/apps/web/src/lib/storage/image-upload.tsindex 169d3bec5..a8c8b4eb7 100644--- a/apps/web/src/lib/storage/image-upload.ts+++ b/apps/web/src/lib/storage/image-upload.ts@@ -1,3 +1,4 @@+import "server-only";import { DeleteObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";import { getSignedUrl } from "@aws-sdk/s3-request-presigner";@@ -59,34 +60,6 @@ export async function getImageUploadUrl({} as const;}-export interface UploadImageParams {- file: File;- url: string;- fileType: "image/jpeg" | "image/png";-}--export async function uploadImage({- file,- url,- fileType,-}: UploadImageParams): Promise<void> {- const response = await fetch(url, {- method: "PUT",- body: file,- headers: {- "Content-Type": fileType,- "Content-Length": file.size.toString(),- },- });-- if (!response.ok) {- throw new AppError({- code: "INTERNAL_SERVER_ERROR",- message: "Failed to upload image to storage",- });- }-}-export async function deleteImageFromS3(imageKey: string) {const s3Client = getS3Client();diff --git a/apps/web/src/lib/storage/upload-client.ts b/apps/web/src/lib/storage/upload-client.tsnew file mode 100644index 000000000..ed9e13408--- /dev/null+++ b/apps/web/src/lib/storage/upload-client.ts@@ -0,0 +1,28 @@+import { AppError } from "@/lib/errors";++export interface UploadImageParams {+ file: File;+ url: string;+ fileType: "image/jpeg" | "image/png";+}++export async function uploadImage({+ file,+ url,+ fileType,+}: UploadImageParams): Promise<void> {+ const response = await fetch(url, {+ method: "PUT",+ body: file,+ headers: {+ "Content-Type": fileType,+ },+ });++ if (!response.ok) {+ throw new AppError({+ code: "INTERNAL_SERVER_ERROR",+ message: "Failed to upload image to storage",+ });+ }+}