metodo upload foto
This commit is contained in:
parent
338c0b9039
commit
fbe6d0ffc9
@ -13969,7 +13969,7 @@ namespace ApiPolo.Controllers
|
|||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
//devo fare la copia del logo e metterlo nella cartella del server a partire dal logo scritto in tabella
|
//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);
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
}
|
}
|
||||||
@ -14091,6 +14091,51 @@ namespace ApiPolo.Controllers
|
|||||||
//System.IO.File.WriteAllBytes("Foo.txt", data);
|
//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
|
||||||
|
{
|
||||||
|
string basePath = _configuration["Percorsi:PathLogo"];
|
||||||
|
string publicBaseUrl = _configuration["Percorsi:PublicBaseUrl"];
|
||||||
|
|
||||||
|
string aziendaFolder = ten2.Trim();
|
||||||
|
string folderPath = Path.Combine(basePath, aziendaFolder);
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
Directory.CreateDirectory(folderPath);
|
||||||
|
|
||||||
|
string fullPath = Path.Combine(folderPath, file.FileName);
|
||||||
|
|
||||||
|
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||||
|
{
|
||||||
|
await file.CopyToAsync(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
/// <summary>VIRTUAL TASK: ricava il nome del file a partire dal path web </summary>
|
||||||
public static string getNomeFile(string path)
|
public static string getNomeFile(string path)
|
||||||
{
|
{
|
||||||
@ -14101,6 +14146,8 @@ namespace ApiPolo.Controllers
|
|||||||
return nome;
|
return nome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>VIRTUAL TASK: dati Azienda</summary>
|
/// <summary>VIRTUAL TASK: dati Azienda</summary>
|
||||||
[HttpGet("rapportiniList")]
|
[HttpGet("rapportiniList")]
|
||||||
public async Task<ActionResult<IEnumerable<Rapportino>>> rapportiniList(string token)
|
public async Task<ActionResult<IEnumerable<Rapportino>>> rapportiniList(string token)
|
||||||
|
|||||||
@ -23,5 +23,9 @@
|
|||||||
"ValidAudience": "http://localhost:4200",
|
"ValidAudience": "http://localhost:4200",
|
||||||
"ValidIssuer": "http://localhost:61955",
|
"ValidIssuer": "http://localhost:61955",
|
||||||
"Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM"
|
"Secret": "ByYM000OLlMQG6VVVp1OH7Xzyr7gHuw1qvUC5dcGt3SNM"
|
||||||
|
},
|
||||||
|
"Percorsi": {
|
||||||
|
"PathLogo": "/zucchetti/api/api-vt.poloinformatico.it/app/wwwroot/VIRTU/",
|
||||||
|
"PublicBaseUrl": "https://api-vt.poloinformatico.it/VIRTU/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user