From 7ddce593f99f9efe95587563718b59c3fd62c65c Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sat, 30 Apr 2022 20:03:09 +0200 Subject: [PATCH] Add max files limit per share --- src/components/upload/Dropzone.tsx | 6 +++++- src/components/upload/FileList.tsx | 2 +- src/pages/api/share/[shareId]/index.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/upload/Dropzone.tsx b/src/components/upload/Dropzone.tsx index 8dafd919..f096a241 100644 --- a/src/components/upload/Dropzone.tsx +++ b/src/components/upload/Dropzone.tsx @@ -65,7 +65,11 @@ const Dropzone = ({ disabled={isUploading} openRef={openRef as ForwardedRef<() => void>} onDrop={(files) => { - setFiles(files); + if (files.length > 100) { + toast.error("You can't upload more than 100 files per share."); + } else { + setFiles(files); + } }} className={classes.dropzone} radius="md" diff --git a/src/components/upload/FileList.tsx b/src/components/upload/FileList.tsx index 23024002..7cd94a44 100644 --- a/src/components/upload/FileList.tsx +++ b/src/components/upload/FileList.tsx @@ -17,7 +17,7 @@ const FileList = ({ }; const rows = files.map((file, i) => ( - + {file.name} {file.type} {bytesToSize(file.size)} diff --git a/src/pages/api/share/[shareId]/index.ts b/src/pages/api/share/[shareId]/index.ts index 9308d5fe..b0fdcba2 100644 --- a/src/pages/api/share/[shareId]/index.ts +++ b/src/pages/api/share/[shareId]/index.ts @@ -20,7 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { addVisitorCount(shareId); - const fileListWithoutPreview = (await awServer.storage.listFiles(shareId)) + const fileListWithoutPreview = (await awServer.storage.listFiles(shareId, undefined, 100)) .files; for (const file of fileListWithoutPreview) {