From 6c5def43a8fd3abf75ef076163d30cc436a14bc3 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Tue, 5 Jun 2018 18:59:58 -0700 Subject: [PATCH] Fixed max upload size not taking into account basic/premium --- Teknik/Areas/API/Controllers/APIv1Controller.cs | 11 ++++++++++- Teknik/Areas/Upload/Controllers/UploadController.cs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Teknik/Areas/API/Controllers/APIv1Controller.cs b/Teknik/Areas/API/Controllers/APIv1Controller.cs index 8f59d17..ed8baf6 100644 --- a/Teknik/Areas/API/Controllers/APIv1Controller.cs +++ b/Teknik/Areas/API/Controllers/APIv1Controller.cs @@ -43,7 +43,16 @@ namespace Teknik.Areas.API.Controllers { if (model.file != null) { - if (model.file.ContentLength <= Config.UploadConfig.MaxUploadSize) + long maxUploadSize = Config.UploadConfig.MaxUploadSize; + if (User.Identity.IsAuthenticated) + { + maxUploadSize = Config.UploadConfig.MaxUploadSizeBasic; + if (User.Info.AccountType == AccountType.Premium) + { + maxUploadSize = Config.UploadConfig.MaxUploadSizePremium; + } + } + if (model.file.ContentLength <= maxUploadSize) { // convert file to bytes string fileExt = Path.GetExtension(model.file.FileName); diff --git a/Teknik/Areas/Upload/Controllers/UploadController.cs b/Teknik/Areas/Upload/Controllers/UploadController.cs index 04b7aeb..e28335c 100644 --- a/Teknik/Areas/Upload/Controllers/UploadController.cs +++ b/Teknik/Areas/Upload/Controllers/UploadController.cs @@ -60,7 +60,16 @@ namespace Teknik.Areas.Upload.Controllers { if (Config.UploadConfig.UploadEnabled) { - if (data.ContentLength <= Config.UploadConfig.MaxUploadSize) + long maxUploadSize = Config.UploadConfig.MaxUploadSize; + if (User.Identity.IsAuthenticated) + { + maxUploadSize = Config.UploadConfig.MaxUploadSizeBasic; + if (User.Info.AccountType == AccountType.Premium) + { + maxUploadSize = Config.UploadConfig.MaxUploadSizePremium; + } + } + if (data.ContentLength <= maxUploadSize) { // convert file to bytes int contentLength = data.ContentLength;