public async Task <DownloadFileByIdQueryResponse> DownloadFileById(Guid id) { var user = await userContext.GetCurrentUserAsync(); var file = await dbContext.Files.FirstOrDefaultAsync(x => x.Id == id && x.UserId == user.Id) ?? throw new NotFoundException("Не удалось найти файл с указанным идентификатором"); var stream = await objectStorage.GetStreamAsync(file.Address); return(new DownloadFileByIdQueryResponse { ContentType = file.ContentType, Name = file.Name, Stream = stream }); }