Beispiel #1
0
        public async Task <IActionResult> Index(IList <IFormFile> files)
        {
            var fileExtension = new[] { "audio/mp3", "audio/mpeg", "audio/ogg", "audio/wav" };

            if (files.Count() > 0)
            {
                var existFolder = _folderService.Exist("Content\\Podcast");
                if (!existFolder)
                {
                    _folderService.Create("Content\\Podcast");
                }

                foreach (var podcast in files)
                {
                    var fileExtensionOk = _fileService.fileExtensionOk(podcast.ContentType, fileExtension);
                    if (fileExtensionOk)
                    {
                        var existFile = _fileService.exist("Content\\Podcast", podcast.FileName);
                        if (!existFile)
                        {
                            var model = new PodcastModel();
                            model.name = podcast.FileName;
                            model.path = "/App_Data/Content/Podcast/" + podcast.FileName;
                            _podcastService.Insert(model);

                            await _fileService.uploadFile("Content\\Podcast", podcast);
                        }
                    }
                }
            }
            return(View());
        }