private async Task <string> ReadFile(string relativeFilePath) { await using Stream readSteam = _webRootFileProvider.GetFileInfo(relativeFilePath).CreateReadStream(); using StreamReader streamReader = new StreamReader(readSteam); return(await streamReader.ReadToEndAsync()); }
private async Task <string> ReadGitFile(string filename) { await using Stream stream = _webRootFileProvider.GetFileInfo(Path.Combine("WingmanTool", "git", filename)).CreateReadStream(); using StreamReader streamReader = new StreamReader(stream); return(await streamReader.ReadToEndAsync()); }
public async Task StoreImageForUserId(string id) { string userImagesPath = _webRootFileProvider.GetFileInfo("user-images").PhysicalPath; string userImagePath = Path.Combine(userImagesPath, $"{id}.png"); using (HttpClient httpClient = new HttpClient()) { using (Stream imageStream = await httpClient.GetStreamAsync($"https://api.adorable.io/avatars/100/{id}.png")) { using (Stream fileStream = File.Create(userImagePath)) { await imageStream.CopyToAsync(fileStream); } } } }