public async Task <ActionResult> AddConnector(CreateConnectorRequestDto connectorData, IFormFile file) { var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads\\ConnectorIcons"); if (!Directory.Exists(uploads)) { Directory.CreateDirectory(uploads); } if (file != null && file.Length > 0) { var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName); var filepath = Path.Combine(uploads, fileName); using (var s = new FileStream(filepath, FileMode.Create)) { await file.CopyToAsync(s); connectorData.Icon = $"Uploads\\ConnectorIcons\\{fileName}"; } } HttpClient client = new HttpClient(); HttpResponseMessage response = await client.PostAsJsonAsync( $"{baseURL}/connectors/", connectorData); response.EnsureSuccessStatusCode(); // return URI of the created resource. return(Json(null)); }
public async Task <ActionResult> Connector_Create([DataSourceRequest] DataSourceRequest request, CreateConnectorRequestDto connectorData) { HttpClient client = new HttpClient(); if (connectorData != null && ModelState.IsValid) { HttpResponseMessage response = await client.PostAsJsonAsync( $"{baseURL}/connectors/", connectorData); response.EnsureSuccessStatusCode(); // return URI of the created resource. } return(Json(new[] { connectorData }.ToDataSourceResult(request, ModelState))); }