Fix fileManager

Added filePath config
This commit is contained in:
Lucio Maranta
2018-09-04 17:06:54 +02:00
parent 757884ebb7
commit 3a0e1bc2a4
12 changed files with 85 additions and 31 deletions
+45 -2
View File
@@ -11,6 +11,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using static CMS_CORE_Library.DataStructures;
using System.Linq;
using static Step.Config.ServerConfig;
using System.ComponentModel.DataAnnotations;
namespace Step.Controllers.WebApi
{
@@ -24,7 +27,7 @@ namespace Step.Controllers.WebApi
{
ncHandler.Connect();
CmsError cmsError = ncHandler.GetFileList(filePath, out List<PreviewFileModel> fileList);
CmsError cmsError = ncHandler.GetFileList(filePath, out List<PreviewFileModel> fileList);
if (cmsError.IsError())
return BadRequest(cmsError.localizationKey);
@@ -33,7 +36,7 @@ namespace Step.Controllers.WebApi
}
[Route("file/info"), HttpGet]
public IHttpActionResult GetFileInfo([FromUri]string filePath)
public IHttpActionResult GetFileInfo([FromUri]string filePath)
{
using (NcHandler ncHandler = new NcHandler())
{
@@ -113,5 +116,45 @@ namespace Step.Controllers.WebApi
return Ok();
}
[Route("shared_files"), HttpGet]
public IHttpActionResult GetSharedFolderFileList(string sharedPath)
{
List<object> filelist = new List<object>();
string sharedFullPath = NcConfig.SharedPath + sharedPath;
if (!Directory.Exists(sharedFullPath))
{
return NotFound();
}
foreach (string item in Directory.GetDirectories(sharedFullPath))
{
filelist.Add(new
{
Name = Path.GetFileName(item),
AbsolutePath = NcConfig.SharedPath + sharedPath,
Path = sharedPath,
IsDirectory = true
});
}
string sharedNcPath = NcConfig.SharedName + sharedPath.Replace('\\', '/');
foreach (string item in Directory.GetFiles(sharedFullPath))
{
if (VALID_FILE_EXTENSIONS.Contains(Path.GetExtension(item).ToLower()))
filelist.Add(new
{
Name = Path.GetFileName(item),
AbsolutePath = sharedNcPath + "/" + Path.GetFileName(item),
Path = sharedPath + "\\" + Path.GetFileName(item),
IsDirectory = false
});
}
return Ok(filelist);
}
}
}