public async Task <FileDto> CreateFileAsync(FileDto fileDto, string token, string bucket) { string url = await _cloudStorageService.UploadFileAsync(fileDto, bucket); string shortUrl = _shortLinkService.GenerateShortLink(url); fileDto.Url = url; fileDto.ShortUrl = shortUrl; return(await _fileService.CreateFileAsync(fileDto, token)); }
public async Task <ActionResult> DbBackups([FromBody] AdminRequest model) { ValidateRequest(model, _adminSettings); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var folderPath = BackupFolder(_adminSettings); string storageFolder = DateTime.Today.ToDateNumber().ToString(); foreach (var filePath in Directory.GetFiles(folderPath)) { var fileInfo = new FileInfo(filePath); await _cloudStorageService.UploadFileAsync(filePath, $"{storageFolder}/{fileInfo.Name}"); } return(Ok()); }