forked from ddrilling/AsbCloudServer
Настройка папки для файлов в appsettings.json
This commit is contained in:
parent
657c542cb2
commit
c8c0ea37fe
@ -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
|
||||
/// <summary>
|
||||
/// Директория хранения файлов
|
||||
/// </summary>
|
||||
private readonly string RootPath = "files";
|
||||
|
||||
public FileStorageRepository()
|
||||
public string RootPath { get; }
|
||||
|
||||
|
||||
public FileStorageRepository(IConfiguration configuration)
|
||||
{
|
||||
RootPath = configuration.GetValue<string>("ContentPath") ?? "files";
|
||||
}
|
||||
|
||||
public async Task SaveFileAsync(string filePathRec, Stream fileStreamSrc, CancellationToken token)
|
||||
|
@ -17,7 +17,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// </summary>
|
||||
[Route("api/well/{idWell}/files")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
//[Authorize]
|
||||
public class FileController : ControllerBase
|
||||
{
|
||||
private readonly FileService fileService;
|
||||
@ -39,7 +39,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Permission]
|
||||
//[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> 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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user