Esempio n. 1
0
        private List <Photo> Photos(List <IFormFile> files)
        {
            DirectoryManagement dm     = new DirectoryManagement();
            List <Photo>        photos = new List <Photo>();

            foreach (var file in files)
            {
                if (file.Length > 0 && file != null)
                {
                    var path = dm.GetFolderPath();

                    var fileName = FileNameManipulator.GenerateName();
                    var fullPath = Path.Combine(path, fileName);
                    var fileType = Path.GetExtension(file.FileName);

                    photos.Add(new Photo()
                    {
                        ImageType = fileType, PhotoDir = fullPath
                    });

                    using (var str = new FileStream(fullPath + fileType, FileMode.Create))
                    {
                        file.CopyTo(str);
                    }
                }
            }
            return(photos);
        }