diff --git a/service/Core/Configuration/ServiceConfig.cs b/service/Core/Configuration/ServiceConfig.cs index e48970d80..0dd5a1ddc 100644 --- a/service/Core/Configuration/ServiceConfig.cs +++ b/service/Core/Configuration/ServiceConfig.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft. All rights reserved. -using System; using System.Collections.Generic; namespace Microsoft.KernelMemory.Configuration; @@ -30,18 +29,8 @@ public class ServiceConfig public Dictionary Handlers { get; set; } = new(); /// - /// The maximum allowed size in megabytes for a request body posted to the upload endpoint. + /// The maximum allowed size in bytes for a request body posted to the upload endpoint. /// If not set the solution defaults to 30,000,000 bytes (~28.6 MB) (ASP.NET default). /// - public long? MaxUploadSizeMb { get; set; } = null; - - public long? GetMaxUploadSizeInBytes() - { - if (this.MaxUploadSizeMb.HasValue) - { - return Math.Min(10, this.MaxUploadSizeMb.Value) * 1024 * 1024; - } - - return null; - } + public long? MaxUploadSize { get; set; } = null; } diff --git a/service/Service.AspNetCore/WebAPIEndpoints.cs b/service/Service.AspNetCore/WebAPIEndpoints.cs index 67dce6132..9cc2ff1cc 100644 --- a/service/Service.AspNetCore/WebAPIEndpoints.cs +++ b/service/Service.AspNetCore/WebAPIEndpoints.cs @@ -26,7 +26,7 @@ public static IEndpointRouteBuilder AddKernelMemoryEndpoints( KernelMemoryConfig? kmConfig = null, IEndpointFilter? authFilter = null) { - builder.AddPostUploadEndpoint(apiPrefix, authFilter, kmConfig?.Service.GetMaxUploadSizeInBytes()); + builder.AddPostUploadEndpoint(apiPrefix, authFilter, kmConfig?.Service.MaxUploadSize); builder.AddGetIndexesEndpoint(apiPrefix, authFilter); builder.AddDeleteIndexesEndpoint(apiPrefix, authFilter); builder.AddDeleteDocumentsEndpoint(apiPrefix, authFilter); diff --git a/service/Service/Program.cs b/service/Service/Program.cs index 9894d0878..ee3da48bb 100644 --- a/service/Service/Program.cs +++ b/service/Service/Program.cs @@ -102,7 +102,7 @@ public static void Main(string[] args) }, services => { - long? maxSize = config.Service.GetMaxUploadSizeInBytes(); + long? maxSize = config.Service.MaxUploadSize; if (!maxSize.HasValue) { return; } services.Configure(x => { x.MaxRequestBodySize = maxSize.Value; }); diff --git a/service/Service/appsettings.json b/service/Service/appsettings.json index 83f71fcca..918c3cbc5 100644 --- a/service/Service/appsettings.json +++ b/service/Service/appsettings.json @@ -44,9 +44,9 @@ "RunWebService": true, // Whether to expose OpenAPI swagger UI at http://127.0.0.1:9001/swagger/index.html "OpenApiEnabled": false, - // The maximum allowed size in MB for the payload posted to the upload endpoint + // The maximum allowed size in bytes for the payload posted to the upload endpoint // If not set the solution defaults to 30,000,000 bytes (~28.6 MB) - "MaxUploadSizeMb": null, + "MaxUploadSize": null, // Whether to run the asynchronous pipeline handlers // Use these booleans to deploy the web service and the handlers on same/different VMs "RunHandlers": true,