Ejemplo n.º 1
0
        private string GetFolderName(ApplicationFolder.ApplicationFolderName folderName)
        {
            switch (folderName)
            {
            case ApplicationFolder.ApplicationFolderName.DefaultUploadFolder:
                return(ApplicationFolder.DefaultUploadFolder);

            case ApplicationFolder.ApplicationFolderName.ImageUploadFolder:
                return(ApplicationFolder.ImageUploadFolder);

            default:
                throw new EntryPointNotFoundException("requested folder doesn't exist in the list");
            }
        }
Ejemplo n.º 2
0
        public async Task <EronFile> SaveFileAsync(HttpPostedFileBase file, ApplicationFolder.ApplicationFolderName folderName)
        {
            if (file != null && file.ContentLength > 0)
            {
                var inputFileName = file.FileName;
                var fileId        = Guid.NewGuid();
                var fileName      = fileId.ToString();

                var fullFolderName = GetFolderName(folderName);

                if (!Directory.Exists(HttpContext.Current.Server.MapPath(fullFolderName)))
                {
                    Directory.CreateDirectory(HttpContext.Current.Server.MapPath(fullFolderName));
                }

                var server = HttpContext.Current.Server.MapPath(fullFolderName);

                var fileNameWithFolder = Path.Combine(server, fileName);

                var result = new EronFile()
                {
                    FileName       = inputFileName,
                    FileUrl        = fullFolderName + fileName,
                    Id             = fileId,
                    FileType       = GetFileType(file),
                    UploadDateTime = DateTime.Now
                };

                file.SaveAs(fileNameWithFolder);
                _unitOfWork.FileRepository.Create(result);
                await _unitOfWork.SaveAsync();

                return(result);
            }
            throw new FileNotFoundException("File is not found");
        }
Ejemplo n.º 3
0
 public bool DeleteDirctory(ApplicationFolder.ApplicationFolderName folderName)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public Task <bool> DeleteDirctoryAsync(ApplicationFolder.ApplicationFolderName folderName)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public Task <List <EronFile> > GetFilesInDirectoryAsync(ApplicationFolder.ApplicationFolderName folderName)
 {
     throw new NotImplementedException();
 }