Skip to content

Commit

Permalink
Max profile picture image size
Browse files Browse the repository at this point in the history
  • Loading branch information
omfj committed Jan 29, 2025
1 parent a8fb063 commit d97f018
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/web/src/actions/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export const uploadProfilePictureAction = async (formData: FormData) => {
};
}

if (file.size / 1024 / 1024 > 5) {
return {
success: false,
message: "Bildet er for stort. Maks 5MB.",
};
}

const imageId = `${user.id}-${Date.now()}`;

const response = await uploadImage(imageId, formData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export const UploadProfilePicture = ({ name, image }: UploadProfilePictureProps)
return;
}

const size = file.size / 1024 / 1024;
if (size > 5) {
toast({ title: "Bildet er for stort. Maks 5MB" });
return;
}

const formData = new FormData();
formData.append("file", file);

Expand Down

0 comments on commit d97f018

Please sign in to comment.