Files
cms_thermo_active/Step/Controllers/WebApi/NcFileController.cs
T
2018-07-27 13:33:57 +02:00

50 lines
1.3 KiB
C#

using Step.NC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using static CMS_CORE_Library.DataStructures;
namespace Step.Controllers.WebApi
{
[RoutePrefix("api/file_manager")]
public class NcFileController : ApiController
{
[Route("files"), HttpGet]
public IHttpActionResult GetFileList(string filePath = "")
{
using (NcHandler ncHandler = new NcHandler())
{
ncHandler.Connect();
CmsError cmsError = ncHandler.GetFileList(filePath, out List<PreviewFileModel> fileList);
if (cmsError.IsError())
return BadRequest(cmsError.localizationKey);
return Ok(fileList);
}
}
[Route("file/info/{*filePath}"), HttpGet]
public IHttpActionResult GetFileInfo(string filePath)
{
using (NcHandler ncHandler = new NcHandler())
{
ncHandler.Connect();
CmsError cmsError = ncHandler.GetFileInfo(filePath, out InfoFile fileInfo);
if (cmsError.IsError())
return BadRequest(cmsError.localizationKey);
return Ok(fileInfo);
}
}
}
}