Upload foto 2
This commit is contained in:
parent
13abd0f91f
commit
5da95be2e4
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using static VirtualTask.Controllers.LoginController;
|
||||
|
||||
namespace VirtualTask.Controllers
|
||||
{
|
||||
@ -6,7 +7,16 @@ namespace VirtualTask.Controllers
|
||||
[Route("foto")]
|
||||
public class FotoController : Controller
|
||||
{
|
||||
private readonly string _rootPath = "/mnt/storagebox";
|
||||
string _rootPath = string.Empty;
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
public FotoController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
var key = _configuration["ApplicationInsights:rootPath"];
|
||||
_rootPath = key;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("{folder}/{fileName}")]
|
||||
public IActionResult ShowOrServe(string folder, string fileName)
|
||||
@ -19,8 +29,6 @@ namespace VirtualTask.Controllers
|
||||
|
||||
// Percorso: /mnt/storagebox/{folder}/PHOTO/{fileName}
|
||||
var filePath = Path.Combine(_rootPath, safeFolder, "PHOTO", safeFileName);
|
||||
|
||||
|
||||
//SOLO PER TEST!!!!!!
|
||||
//filePath = "C:\\DATI\\V000000009_2.jpg";
|
||||
|
||||
@ -28,25 +36,6 @@ namespace VirtualTask.Controllers
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
return NotFound("File non trovato");
|
||||
|
||||
//var acceptHeader = Request.Headers["Accept"].ToString();
|
||||
|
||||
//if (!string.IsNullOrEmpty(acceptHeader) && acceptHeader.Contains("image"))
|
||||
//{
|
||||
// // rileva content-type dinamico
|
||||
// var ext = Path.GetExtension(safeFileName).ToLowerInvariant();
|
||||
// var contentType = ext switch
|
||||
// {
|
||||
// ".png" => "image/png",
|
||||
// ".webp" => "image/webp",
|
||||
// ".jpg" or ".jpeg" => "image/jpeg",
|
||||
// _ => "application/octet-stream"
|
||||
// };
|
||||
|
||||
// var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
// return File(stream, contentType);
|
||||
//}
|
||||
|
||||
// Se non è richiesta immagine → mostra view Razor
|
||||
ViewBag.Folder = safeFolder;
|
||||
ViewBag.FileName = safeFileName;
|
||||
return View("ShowImage");
|
||||
|
||||
@ -19,11 +19,28 @@
|
||||
<a asp-action="Index" asp-controller="MagNewVT" asp-route-serRapp="@Model.seriale_rapportino" value="Mag new" class="agy-btn submitForm">Mag New</a>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<div class="card" style="width:80%">
|
||||
<h5 class="card-header">Dettaglio buono</h5>
|
||||
<div class="table-responsive text-nowrap">
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<b>@Html.DisplayNameFor(model => model.azienda_impianto)</b> @Html.DisplayFor(model => model.azienda_impianto)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>@Html.DisplayNameFor(model => model.seriale_rapportino)</b> @Html.DisplayFor(model => model.seriale_rapportino)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.azienda_impianto)</b> @Html.DisplayFor(model => model.azienda_impianto)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.seriale_rapportino)</b> @Html.DisplayFor(model => model.seriale_rapportino)
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-10">
|
||||
@ -318,21 +335,23 @@
|
||||
|
||||
|
||||
|
||||
@{
|
||||
if (!string.IsNullOrEmpty(Model.rafoto1))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<a href="@Url.Action("ShowOrServe", "Foto", new { folder = Model.azienda_impianto, fileName = Model.rafoto1 })">
|
||||
@Html.DisplayNameFor(model => model.rafoto1)
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@{
|
||||
if (!string.IsNullOrEmpty(Model.rafoto1))
|
||||
{
|
||||
// <div class="col-md-10">
|
||||
// <b>@Html.DisplayNameFor(model => model.rafoto1)</b> @Html.DisplayFor(model => model.rafoto1)
|
||||
// </div>
|
||||
<div>
|
||||
<a href="@Url.Action("ShowOrServe", "Foto", new { folder = Model.azienda_impianto, fileName = Model.rafoto1 })">
|
||||
Immagine: @Html.DisplayNameFor(model => model.rafoto1)
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
"rootUrlApi2": "https://api-vt.poloinformatico.it/VIRTU/",
|
||||
"rootWebLoghi": "C:\\ZAPIPOLO\\api_polo\\wwwroot\\VIRTU\\",
|
||||
"rootUrl": "https://virtualtask.it/",
|
||||
"rootPath": "/mnt/storagebox",
|
||||
|
||||
//TEST
|
||||
//"rootUrlApi": "http://testapi.poloinformatico.it:9001/api/Polo/",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user