From c8c0ea37fe5365a1efa60b3afd927e879886fe55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 00:26:47 +0500 Subject: [PATCH 1/7] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B2=20appset?= =?UTF-8?q?tings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/FileStorageRepository.cs | 9 +++++++-- AsbCloudWebApi/Controllers/FileController.cs | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/FileStorageRepository.cs b/AsbCloudInfrastructure/Repository/FileStorageRepository.cs index 7fad445b..4f9293ec 100644 --- a/AsbCloudInfrastructure/Repository/FileStorageRepository.cs +++ b/AsbCloudInfrastructure/Repository/FileStorageRepository.cs @@ -6,6 +6,8 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; + namespace AsbCloudInfrastructure.Repository; @@ -14,10 +16,13 @@ public class FileStorageRepository : IFileStorageRepository /// /// Директория хранения файлов /// - private readonly string RootPath = "files"; - public FileStorageRepository() + public string RootPath { get; } + + + public FileStorageRepository(IConfiguration configuration) { + RootPath = configuration.GetValue("ContentPath") ?? "files"; } public async Task SaveFileAsync(string filePathRec, Stream fileStreamSrc, CancellationToken token) diff --git a/AsbCloudWebApi/Controllers/FileController.cs b/AsbCloudWebApi/Controllers/FileController.cs index e9a7990b..713b3731 100644 --- a/AsbCloudWebApi/Controllers/FileController.cs +++ b/AsbCloudWebApi/Controllers/FileController.cs @@ -17,7 +17,7 @@ namespace AsbCloudWebApi.Controllers /// [Route("api/well/{idWell}/files")] [ApiController] - [Authorize] + //[Authorize] public class FileController : ControllerBase { private readonly FileService fileService; @@ -39,7 +39,7 @@ namespace AsbCloudWebApi.Controllers /// Токен отмены задачи /// [HttpPost] - [Permission] + //[Permission] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] public async Task SaveFilesAsync(int idWell, int idCategory, [FromForm] IFormFileCollection files, [FromServices] IUserRepository userRepository, CancellationToken token) @@ -60,7 +60,7 @@ namespace AsbCloudWebApi.Controllers foreach (var file in files) { var fileStream = file.OpenReadStream(); - await fileService.SaveAsync(idWell, idUser ?? 0, idCategory, file.FileName, + await fileService.SaveAsync(idWell, idUser ?? 1, idCategory, file.FileName, fileStream, token).ConfigureAwait(false); } From 183d07639e21ea689c1e283ef2fa48e9af318639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 10:42:02 +0500 Subject: [PATCH 2/7] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Controllers/FileController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AsbCloudWebApi/Controllers/FileController.cs b/AsbCloudWebApi/Controllers/FileController.cs index 713b3731..e9a7990b 100644 --- a/AsbCloudWebApi/Controllers/FileController.cs +++ b/AsbCloudWebApi/Controllers/FileController.cs @@ -17,7 +17,7 @@ namespace AsbCloudWebApi.Controllers /// [Route("api/well/{idWell}/files")] [ApiController] - //[Authorize] + [Authorize] public class FileController : ControllerBase { private readonly FileService fileService; @@ -39,7 +39,7 @@ namespace AsbCloudWebApi.Controllers /// Токен отмены задачи /// [HttpPost] - //[Permission] + [Permission] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] public async Task SaveFilesAsync(int idWell, int idCategory, [FromForm] IFormFileCollection files, [FromServices] IUserRepository userRepository, CancellationToken token) @@ -60,7 +60,7 @@ namespace AsbCloudWebApi.Controllers foreach (var file in files) { var fileStream = file.OpenReadStream(); - await fileService.SaveAsync(idWell, idUser ?? 1, idCategory, file.FileName, + await fileService.SaveAsync(idWell, idUser ?? 0, idCategory, file.FileName, fileStream, token).ConfigureAwait(false); } From 8870931348acfe250e039c35d73259b0897509c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 10:57:13 +0500 Subject: [PATCH 3/7] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20ContentPath=20=D0=B2=20appsettings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/appsettings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/AsbCloudWebApi/appsettings.json b/AsbCloudWebApi/appsettings.json index 96a3f3bf..73c98743 100644 --- a/AsbCloudWebApi/appsettings.json +++ b/AsbCloudWebApi/appsettings.json @@ -16,6 +16,7 @@ //"userLimits": { // "parallelRequestsToController": 5 //}, + "ContentPath": "…\\data", "email": { "smtpServer": "smtp.timeweb.ru", "sender": "bot@digitaldrilling.ru", From 9c3887092da662254d2bf0221eef8488bd2e96d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 12:25:57 +0500 Subject: [PATCH 4/7] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20Cont?= =?UTF-8?q?entPath=20=D0=B2=20appsettings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsbCloudWebApi/appsettings.json b/AsbCloudWebApi/appsettings.json index 73c98743..c8b0198c 100644 --- a/AsbCloudWebApi/appsettings.json +++ b/AsbCloudWebApi/appsettings.json @@ -16,7 +16,7 @@ //"userLimits": { // "parallelRequestsToController": 5 //}, - "ContentPath": "…\\data", + "ContentPath": "../data", "email": { "smtpServer": "smtp.timeweb.ru", "sender": "bot@digitaldrilling.ru", From 9cdf29c6c54ef853d4016968c567111bf4ec2b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 16:48:00 +0500 Subject: [PATCH 5/7] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudInfrastructure/Repository/FileStorageRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsbCloudInfrastructure/Repository/FileStorageRepository.cs b/AsbCloudInfrastructure/Repository/FileStorageRepository.cs index 4f9293ec..50e9bff5 100644 --- a/AsbCloudInfrastructure/Repository/FileStorageRepository.cs +++ b/AsbCloudInfrastructure/Repository/FileStorageRepository.cs @@ -22,7 +22,7 @@ public class FileStorageRepository : IFileStorageRepository public FileStorageRepository(IConfiguration configuration) { - RootPath = configuration.GetValue("ContentPath") ?? "files"; + RootPath = configuration.GetValue("ContentPath") ?? "../data"; } public async Task SaveFileAsync(string filePathRec, Stream fileStreamSrc, CancellationToken token) From 82a4d11ccff1064a32e148862082d31590961a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Fri, 19 Jan 2024 16:55:27 +0500 Subject: [PATCH 6/7] =?UTF-8?q?=D0=9F=D0=B0=D0=BF=D0=BA=D0=B0=20data=20g?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B0=20=D0=B2?= =?UTF-8?q?=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fc614d65..ca13ffd6 100644 --- a/.gitignore +++ b/.gitignore @@ -339,4 +339,5 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb +data/ \ No newline at end of file From 5bcffd1ffe263d92afbbf4298c487cbd9239de07 Mon Sep 17 00:00:00 2001 From: Frolov-Nikita Date: Sun, 21 Jan 2024 12:21:23 +0500 Subject: [PATCH 7/7] clean appsettings.json --- AsbCloudWebApi/appsettings.json | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/AsbCloudWebApi/appsettings.json b/AsbCloudWebApi/appsettings.json index c8b0198c..72d50f57 100644 --- a/AsbCloudWebApi/appsettings.json +++ b/AsbCloudWebApi/appsettings.json @@ -13,9 +13,6 @@ "LocalConnection": "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True" }, "AllowedHosts": "*", - //"userLimits": { - // "parallelRequestsToController": 5 - //}, "ContentPath": "../data", "email": { "smtpServer": "smtp.timeweb.ru", @@ -29,28 +26,5 @@ }, "DirectoryNameHelpPageFiles": "helpPages", "DirectoryManualFiles": "manuals", - "Urls": "http://0.0.0.0:5000" //;https://0.0.0.0:5001" //, - // See https man: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-6.0 - //"Kestrel": { - // "Endpoints": { - // "Http": { - // "Url": "http://0.0.0.0:5000" - // }, - // "Https": { - // "Url": "https://0.0.0.0:5001", - // "Certificate": { - // // use store - // "Subject": "localhost", - // "Store": "My", - // "Location": "CurrentUser", - // "AllowInvalid": true - - // // use file - // "Path": "", - // "KeyPath": "", - // "Password": "" - // } - // } - // } - //} + "Urls": "http://0.0.0.0:5000" }