/// <summary>
        /// TODO - effective linking of saved files in FileTable with DwsFIleInfo.....
        /// ???
        /// </summary>
        /// <param name="uploadInfo"></param>
        public List <DwsFileInfo> SaveUploadFiles(DwsFileUpload uploadInfo)
        {
            List <DwsFileInfo> fileInfo  = new List <DwsFileInfo>();
            string             uploadDir = GetUploadDir(uploadInfo.SessionId);

            foreach (var file in uploadInfo.Files)
            {
                if (file.Length > 0)
                {
                    var fileName = file.FileName;

                    var fileInfoNew = new DwsFileInfo(fileName, uploadDir)
                    {
                        FriendlyName     = Path.GetFileNameWithoutExtension(fileName),
                        Description      = uploadInfo.Description,
                        CreatedTimestamp = DateTime.UtcNow,
                        UpdatedTimestamp = DateTime.UtcNow,
                        MimeType         = file.ContentType,
                        FileSize         = file.Length,
                        SessionId        = uploadInfo.SessionId
                    };

                    SaveFile(file, fileInfoNew);
                    fileInfo.Add(fileInfoNew);
                }
            }
            return(SaveFileInfo(fileInfo));
        }
예제 #2
0
        //[ServiceFilter(typeof(ValidateMimeMultipartContentFilter))]
        public IActionResult UploadFiles(DwsFileUpload uploadInfo)
        {
            //try
            //{
            uploadInfo.SessionId = Request.Cookies["DwsSessionToken"];
            List <DwsFileInfo> fileinfo = FileRepository.SaveUploadFiles(uploadInfo);

            FileRepository.CommitTransaction();     //like to avoid this, but can't share transaction with Ajax!!?? TODO
            Response.StatusCode = 200;
            return(Json(fileinfo));

            //}
            //catch (Exception ex)
            //{
            //    Response.StatusCode = 500;
            //    var serverEx = new ServerException() { MiscException = ex };
            //    return PartialView("~/Views/Shared/_ServerError.cshtml", serverEx); ;
            //}
        }