usingMicrosoft.AspNetCore.Mvc;usingMicrosoft.AspNetCore.SignalR;usingSignalRAPI.Hubs;usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Net.Http;usingSystem.Threading.Tasks;// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860namespaceSignalRAPI.Controllers{[Route("api/[controller]/[action]")][ApiController]publicclassDownLoadController:ControllerBase{privateIHttpClientFactory _httpClientFactory;publicDownLoadController(IHubContext<ChatHub> HubContext,IHttpClientFactory httpClientFactory){_httpClientFactory = httpClientFactory;}[HttpPost]publicasyncvoidDownLoadFromUrl([FromQuery]string url,string name){if(!System.IO.File.Exists(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name))){var client = _httpClientFactory.CreateClient();byte[] fileBytes =await client.GetByteArrayAsync(url);System.IO.File.WriteAllBytes(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name), fileBytes);_HubContext.Clients.All.SendAsync("download", name);}_HubContext.Clients.All.SendAsync("download", name);}// POST api/<DownLoadController>[HttpPost]publicvoidPost([FromBody]stringvalue){}}}