Merge branch 'main' of https://gitea.poloinformatico.it/POLO-API/ApiVirtualTask
This commit is contained in:
commit
f78e78b231
@ -13523,7 +13523,7 @@ namespace ApiPolo.Controllers
|
||||
transaction.Commit();
|
||||
}
|
||||
//devo fare la copia del logo e metterlo nella cartella del server a partire dal logo scritto in tabella
|
||||
model = await readImgAndSave(model.azienda, model.tecnico, _confLette.path_buoni);
|
||||
//model = await readImgAndSave(model.azienda, model.tecnico, _confLette.path_buoni);
|
||||
|
||||
return StatusCode(StatusCodes.Status200OK, model);
|
||||
}
|
||||
@ -13645,6 +13645,55 @@ namespace ApiPolo.Controllers
|
||||
//System.IO.File.WriteAllBytes("Foo.txt", data);
|
||||
}
|
||||
|
||||
[HttpPost("datiazienda/upload_logo")]
|
||||
public async Task<IActionResult> UploadLogo(IFormFile file, string token)
|
||||
{
|
||||
string ten = getClaimValueByToken(token, "tenant");
|
||||
string ten2 = getClaimValueByToken(token, "tenant2");
|
||||
|
||||
if (file == null || file.Length == 0)
|
||||
return BadRequest("Nessun file ricevuto");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ten2))
|
||||
return BadRequest("Parametro azienda mancante");
|
||||
|
||||
try
|
||||
{
|
||||
// Percorso base su Linux (già presente nella macchina server)
|
||||
string basePath = _configuration["Percorsi:PathLogo"];
|
||||
|
||||
// Cartella azienda, es. "AZI02"
|
||||
string aziendaFolder = ten2.Trim();
|
||||
|
||||
// Costruisco il percorso completo in modo portabile
|
||||
string folderPath = Path.Combine(basePath, aziendaFolder);
|
||||
// Percorso finale del file
|
||||
string fullPath = Path.Combine(folderPath, file.FileName);
|
||||
|
||||
// Salvo il file fisicamente
|
||||
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
|
||||
// URL pubblico (se la cartella è servita via web)
|
||||
string publicBaseUrl = _configuration["Percorsi:PublicBaseUrl"];
|
||||
string fileUrl = $"{publicBaseUrl}{aziendaFolder}/{file.FileName}";
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
message = "Logo caricato con successo",
|
||||
url = fileUrl,
|
||||
fileName = file.FileName,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Errore durante il salvataggio: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>VIRTUAL TASK: ricava il nome del file a partire dal path web </summary>
|
||||
public static string getNomeFile(string path)
|
||||
{
|
||||
@ -13655,6 +13704,8 @@ namespace ApiPolo.Controllers
|
||||
return nome;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>VIRTUAL TASK: dati Azienda</summary>
|
||||
[HttpGet("rapportiniList")]
|
||||
public async Task<ActionResult<IEnumerable<Rapportino>>> rapportiniList(string token)
|
||||
|
||||
@ -23,5 +23,9 @@
|
||||
"ValidAudience": "http://localhost:4200",
|
||||
"ValidIssuer": "http://localhost:61955",
|
||||
"Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM"
|
||||
},
|
||||
"Percorsi": {
|
||||
"PathLogo": "./wwwroot/VIRTU",
|
||||
"PublicBaseUrl": "https://api-vt.poloinformatico.it/VIRTU/"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user