Skip to content

Commit

Permalink
feat: uplaod size to big msg #95
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsJacobsen committed Feb 27, 2023
1 parent 752fd24 commit 62436b8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server/aws/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Upload files to aws

import { toast } from "react-hot-toast";
import { uploadType } from "../../client/components/Dropzone";

export const uploadFile = async (
Expand All @@ -10,8 +11,11 @@ export const uploadFile = async (
if (!file) return;

const maxFileSize = 2 * 1024 * 1024; // 2 MB in bytes
console.log(file.size);
if (file.size > maxFileSize) {
console.log(maxFileSize);
console.error(`File size of ${file.size} bytes exceeds the 2 MB limit.`);
toast.error("File size is bigger than 2 MB limit.");
return;
}

Expand Down Expand Up @@ -42,6 +46,7 @@ export const uploadFile = async (
console.log("Uploaded successfully!");
return createFileUrl(file, userId, type, date);
} else {
toast.error("Upload failed");
console.error("Upload failed.");
}
};
Expand Down

0 comments on commit 62436b8

Please sign in to comment.