From 774117c3cefac2dc2c1e392122016dcb5d469da9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 4 Feb 2022 13:34:44 +0100 Subject: [PATCH] Fix path x invio file su share --- LiMan.Api/Controllers/FilesaveController.cs | 32 ++++++++++++++------- LiMan.Api/LiMan.APi.xml | 5 +++- LiMan.Api/appsettings.json | 3 +- LiMan.UI/LiMan.UI.csproj | 2 +- LiMan.UI/Resources/ChangeLog.html | 2 +- LiMan.UI/Resources/VersNum.txt | 2 +- LiMan.UI/Resources/manifest.xml | 2 +- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/LiMan.Api/Controllers/FilesaveController.cs b/LiMan.Api/Controllers/FilesaveController.cs index 883afb9..d187aa3 100644 --- a/LiMan.Api/Controllers/FilesaveController.cs +++ b/LiMan.Api/Controllers/FilesaveController.cs @@ -9,6 +9,7 @@ using LiMan.DB.DBModels; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; namespace LiMan.APi.Controllers @@ -22,6 +23,7 @@ namespace LiMan.APi.Controllers { private readonly IWebHostEnvironment env; private readonly ILogger logger; + private static IConfiguration _configuration; /// /// Dataservice x accesso DB @@ -31,10 +33,14 @@ namespace LiMan.APi.Controllers /// /// Init generico /// + /// /// - public FilesaveController(ApiDataService DataService, IWebHostEnvironment env, ILogger logger) + /// + /// + public FilesaveController(IConfiguration configuration, ApiDataService DataService, IWebHostEnvironment env, ILogger logger) { dataService = DataService; + _configuration = configuration; this.env = env; this.logger = logger; logger.LogInformation("Avviata classe FilesaveController"); @@ -50,10 +56,10 @@ namespace LiMan.APi.Controllers [HttpPost("single")] public async Task> PostSingleFile([FromForm] int ticketId, [FromForm] IFormFile file) { - // max 20 mb - long maxFileSize = 1024 * 1024 * 20; + // max 200 mb + long maxFileSize = 1024 * 1024 * 200; string ticketDir = $"T{ticketId:000000000}"; - var resourcePath = new Uri($"{Request.Scheme}://{Request.Host}/api/filesave/{ticketDir}"); + var resourcePath = new Uri($"{Request.Scheme}://{Request.Host}/api/filesave/list/{ticketId}"); List uploadResults = new(); string fileDir = env.ContentRootPath; string relDir = env.EnvironmentName; @@ -80,9 +86,13 @@ namespace LiMan.APi.Controllers { DateTime oggi = DateTime.Today; trustedFileNameForFileStorage = Path.GetRandomFileName(); +#if false relDir = Path.Combine(env.EnvironmentName, "unsafe_uploads", ticketDir); fileDir = Path.Combine(env.ContentRootPath, relDir); - //string fileDir = Path.Combine(env.ContentRootPath, env.EnvironmentName, "unsafe_uploads", $"{oggi:yyyy}", $"{oggi:MM}", $"{oggi:dd}"); + //string fileDir = Path.Combine(env.ContentRootPath, env.EnvironmentName, "unsafe_uploads", $"{oggi:yyyy}", $"{oggi:MM}", $"{oggi:dd}"); +#endif + relDir = _configuration["FileShare"]; + fileDir = Path.Combine(relDir, ticketDir); if (!Directory.Exists(fileDir)) { Directory.CreateDirectory(fileDir); @@ -119,13 +129,13 @@ namespace LiMan.APi.Controllers [HttpPost()] public async Task>> PostFiles([FromForm] int ticketId, [FromForm] IEnumerable files) { - // max 3 files - var maxAllowedFiles = 3; - // max 20 mb - long maxFileSize = 1024 * 1024 * 20; + // max 5 files + var maxAllowedFiles = 10; + // max 50 mb + long maxFileSize = 1024 * 1024 * 50; var filesProcessed = 0; string ticketDir = $"T{ticketId:000000000}"; - var resourcePath = new Uri($"{Request.Scheme}://{Request.Host}/api/filesave/{ticketDir}"); + var resourcePath = new Uri($"{Request.Scheme}://{Request.Host}/api/filesave/list/{ticketId}"); List uploadResults = new(); string fileDir = env.ContentRootPath; string relDir = env.EnvironmentName; @@ -210,7 +220,7 @@ namespace LiMan.APi.Controllers { // cerco i files dato ticket result = await dataService.FileGetFilt(id); - //await dataService.recordCall(CurrRequest.CodInst, CurrRequest.CodApp, $"POST:api/files/list:{id}"); + await dataService.recordCall(CurrRequest.CodInst, CurrRequest.CodApp, $"POST:api/files/list:{id}"); } return result; } diff --git a/LiMan.Api/LiMan.APi.xml b/LiMan.Api/LiMan.APi.xml index d094465..64f14e3 100644 --- a/LiMan.Api/LiMan.APi.xml +++ b/LiMan.Api/LiMan.APi.xml @@ -103,11 +103,14 @@ Dataservice x accesso DB - + Init generico + + + diff --git a/LiMan.Api/appsettings.json b/LiMan.Api/appsettings.json index 77041ab..9eaca6a 100644 --- a/LiMan.Api/appsettings.json +++ b/LiMan.Api/appsettings.json @@ -41,5 +41,6 @@ } ], "Database": 14 - } + }, + "FileShare": "\\\\stor01\\TEAM DRIVES\\40_FileUpload\\unsafe_uploads" } \ No newline at end of file diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 0bf83cb..e7ba1d2 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.1.2202.0409 + 1.1.2202.0413 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index d43bdf9..5e7b06f 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 1.1.2202.0409

+

Versione: 1.1.2202.0413


Note di rilascio:
    diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 4ed29e8..4a54ca6 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2202.0409 +1.1.2202.0413 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 823f8e8..eff49e0 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2202.0409 + 1.1.2202.0413 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false