|
|
|
@@ -1,5 +1,4 @@ |
|
|
|
using System.Text.Json; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.StaticFiles; |
|
|
|
using SecureSharing.Business.Dtos; |
|
|
|
@@ -44,13 +43,13 @@ public sealed class HomeController : Controller |
|
|
|
var message = new MessageDto { Text = model.Text }; |
|
|
|
|
|
|
|
var basePath = Path.Combine(_webHostEnvironment.WebRootPath.Split('/')[0], DefaultPath, message.Code.ToString()); |
|
|
|
// var basePath = $"C:\\Users\\radivoje.milutinovic\\Downloads\\fajlovitmp\\{message.Code}"; |
|
|
|
Directory.CreateDirectory(basePath); |
|
|
|
|
|
|
|
foreach (var formFile in model.Files) |
|
|
|
{ |
|
|
|
if (formFile.Length <= 0) continue; |
|
|
|
// Console.WriteLine(JsonSerializer.Serialize(formFile)); |
|
|
|
if (formFile.Length <= 0) |
|
|
|
continue; |
|
|
|
|
|
|
|
var filePath = Path.Combine(basePath, formFile.FileName); |
|
|
|
await using var stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite); |
|
|
|
await formFile.CopyToAsync(stream); |
|
|
|
@@ -68,10 +67,8 @@ public sealed class HomeController : Controller |
|
|
|
await using var stream = new FileStream(path, FileMode.Open); |
|
|
|
await stream.CopyToAsync(memory); |
|
|
|
memory.Position = 0; |
|
|
|
string? contentType; |
|
|
|
new FileExtensionContentTypeProvider().TryGetContentType(filename, out contentType); |
|
|
|
new FileExtensionContentTypeProvider().TryGetContentType(filename, out var contentType); |
|
|
|
return contentType is null ? null : File(memory, contentType,Path.GetFileName(path)); |
|
|
|
// Response.Redirect(); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |