From 21e20ad2b7412ab0848b22d477b8334f36d6765c Mon Sep 17 00:00:00 2001 From: limited_dev Date: Tue, 13 Jun 2023 07:47:49 +0200 Subject: [PATCH] feat: increase file upload size limit to 10MiB Signed-off-by: limited_dev --- .../Shared/Components/Forms/CommentForm.razor | 4 ++-- ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor | 2 +- ImageBoardServerApp/Shared/Components/Forms/PostForm.razor | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor index 342ab67..caaf03e 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor @@ -136,12 +136,12 @@ bool hasImage = selectedFile != null; int thisGET = b.NumberOfGETs + 1; - b.NumberOfGETs++; + ++b.NumberOfGETs; await BoardsRepository.updateBoardAsync(b); CommentData commentToCreate; if (hasImage) { - Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 8); // max 4MB + Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 2 * 10); // max 10MB var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1]; var path = $"{env.WebRootPath}/img/dynamic/comment/{@post.Board}/{@file}"; FileStream fs = File.Create(path); diff --git a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor index 9b7f853..0a3941c 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor @@ -1,5 +1,5 @@ 
- The max. image size is 4MiB. + The max. image size is 10MiB.
Supported file types are: jpeg, png & gif
diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor index 18d0f9e..a0b7960 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor @@ -137,14 +137,14 @@ //TODO Add check if data is image - if (selectedFile == null || selectedFile.Size >= 512000 * 4) + if (selectedFile == null || selectedFile.Size >= 512000 * 2 * 10) { hasErr = true; - postErr = "You did not attach a file or the selected file is bigger then the 2MiB file limit."; + postErr = "You did not attach a file or the selected file is bigger then the 10MiB file limit."; return; } - Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 8); // max 4MB + Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 2 * 10); // max 10MB var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1]; var path = $"{env.WebRootPath}/img/dynamic/op/{@board.Tag}/{@file}"; FileStream fs = File.Create(path);