Fényképek letöltése programból
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.BaseStock.ImageFiles
|
||||
{
|
||||
[Authorize]
|
||||
public class ImageFilesPageModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly ISystemService _systemService;
|
||||
public ImageFilesPageModel(ILogger<IndexModel> logger, ISystemService systemService)
|
||||
{
|
||||
_logger = logger;
|
||||
_systemService = systemService;
|
||||
}
|
||||
public async Task OnGet()
|
||||
{
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadImageFiles()
|
||||
{
|
||||
var results = await _systemService.GetAllImageFilesAsync();
|
||||
return new JsonResult(new { data = results });
|
||||
}
|
||||
public async Task<IActionResult> OnGetDownloadFile(string filename)
|
||||
{
|
||||
var response = await _systemService.DownloadFile(filename);
|
||||
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
var result = new FileContentResult(response.Data, "application/octet-stream")
|
||||
{
|
||||
FileDownloadName = filename,
|
||||
FileContents = response.Data
|
||||
};
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user