From 4870bdb5354bb54b3f39454d0330379942104ff6 Mon Sep 17 00:00:00 2001 From: surendrakoritalanewsignature <68114451+surendrakoritalanewsignature@users.noreply.github.com> Date: Wed, 15 Jul 2020 10:11:59 -0400 Subject: [PATCH] Commit #2: Made changes to handle size limits of 4GB --- Controllers/AzureProviderController.cs | 4 +++- Models/AzureFileProvider.cs | 14 ++++++------- Startup.cs | 5 +++++ web.config | 27 +++++++++++++------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Controllers/AzureProviderController.cs b/Controllers/AzureProviderController.cs index 7ff3237..4c62d6d 100644 --- a/Controllers/AzureProviderController.cs +++ b/Controllers/AzureProviderController.cs @@ -20,7 +20,7 @@ public AzureProviderController(IHostingEnvironment hostingEnvironment) { this.operation = new AzureFileProvider(); // Create a storage account in azure, modify storage name, key, - this.operation.RegisterAzure("samplestorageaccount10", "HDTtipcpTx44LAKfnnWon1bhFZfZVpE6Vt5ToWihBPOgPmKOPkayd+i902eCm3V2Ms1dEi2df4JuKrrdbSoXOw==", "files"); + this.operation.RegisterAzure("samplestorageaccount10", "QMdPLhIgZGRaHh3uHmIfEnGl/Qq+QWRtisvrZkQZcVlvdU/Gn4AKBMYZ0Uj1g04qrb/fMWxX3extH3ljTBIJNw==", "files"); this.operation.SetBlobContainer("https://samplestorageaccount10.blob.core.windows.net/files/", "https://samplestorageaccount10.blob.core.windows.net/files/Files"); //---------- //For example @@ -29,6 +29,8 @@ public AzureProviderController(IHostingEnvironment hostingEnvironment) //--------- } [Route("AzureFileOperations")] + [RequestFormLimits(MultipartBodyLengthLimit = 4294967270)] + [RequestSizeLimit(4294967270)] public object AzureFileOperations([FromBody] FileManagerDirectoryContent args) { if (args.Path != "") diff --git a/Models/AzureFileProvider.cs b/Models/AzureFileProvider.cs index d841d24..e2f20a5 100644 --- a/Models/AzureFileProvider.cs +++ b/Models/AzureFileProvider.cs @@ -470,18 +470,18 @@ protected async Task UploadAsync(IEnumerable fil string absoluteFilePath = Path.Combine(Path.GetTempPath(), fileName); if (action == "save") { - if (!File.Exists(absoluteFilePath)) - { + //if (!File.Exists(absoluteFilePath)) + //{ using (FileStream fs = File.Create(absoluteFilePath)) { await blockBlob.UploadFromStreamAsync(file.OpenReadStream()); fs.Flush(); } - } - else - { - existFiles.Add(fileName); - } + //} + //else + //{ + // existFiles.Add(fileName); + //} } else if (action == "delete") { diff --git a/Startup.cs b/Startup.cs index cdedb98..147a824 100644 --- a/Startup.cs +++ b/Startup.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; @@ -36,6 +37,10 @@ public void ConfigureServices(IServiceCollection services) .AllowAnyHeader(); }); }); + services.Configure(x => + { + x.MultipartBodyLengthLimit = 4294967270; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/web.config b/web.config index 85f1af1..cf7e5ea 100644 --- a/web.config +++ b/web.config @@ -1,15 +1,16 @@  - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + \ No newline at end of file