Example #1
0
        public Task DeleteAsync(string fileName, FileDestinations type)
        {
            var filePath = Path.Combine(_folders[type], fileName);

            File.Delete(filePath);

            return(Task.CompletedTask);
        }
Example #2
0
        public async Task <string> SaveAsync(IFileAttachment file, FileDestinations type)
        {
            var directoryPath = _folders[type];

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            var fileName = $"{Guid.NewGuid()}{Path.GetExtension(file.FileName)}";
            var fullName = Path.Combine(directoryPath, fileName);

            await using (var stream = File.Create(fullName))
            {
                await file.CopyToAsync(stream);
            }

            _sessionPaths.Add(fullName);
            return(fileName);
        }
Example #3
0
 public Task <byte[]> LoadAsync(string fileName, FileDestinations type)
 {
     return(File.ReadAllBytesAsync(Path.Combine(_folders[type], fileName)));
 }