Skip to content

Commit

Permalink
Add max file upload env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
karlromets committed Dec 27, 2024
1 parent 56de767 commit 586dfd1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
NEXT_PUBLIC_TITLE_URL='famf.app'
NEXT_PUBLIC_TITLE_URL='famf.app'
NEXT_PUBLIC_MAX_IMAGE_UPLOAD_SIZE_MB=2
NEXT_PUBLIC_MAX_CSV_UPLOAD_SIZE_MB=2
15 changes: 12 additions & 3 deletions components/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ function TitleLogoUpload(props) {
var file = document.getElementById("logoUpload").files[0];

if (file) {
const fileSize = Math.round(file.size / 1024);
// 2MB
if (fileSize > 2098) {
if (file.size > process.env.NEXT_PUBLIC_MAX_IMAGE_UPLOAD_SIZE_MB * 1024 * 1024) {
console.error("Logo image is too large");
props.setError(
t("Logo image is too large. 2MB is the limit"),
Expand Down Expand Up @@ -538,6 +536,17 @@ export default function Admin(props) {
id="gamePicker"
onChange={(e) => {
var file = document.getElementById("gamePicker").files[0];

if (file) {
if (file.size > process.env.NEXT_PUBLIC_MAX_CSV_UPLOAD_SIZE_MB * 1024 * 1024) {
console.error("This csv file is too large");
props.setError(
t("This csv file is too large"),
);
return;
}
}

console.debug(file);
if (file?.type === "application/json") {
if (file) {
Expand Down

0 comments on commit 586dfd1

Please sign in to comment.