public async Task <IActionResult> ImportServiceData([FromForm] ImportServiceDataRequest importServiceDataRequest) { byte[] fileContentBytes = await ReadFileContentBytes(importServiceDataRequest); await _serviceDataService.ImportAsync(fileContentBytes); return(Ok()); }
private async Task <byte[]> ReadFileContentBytes(ImportServiceDataRequest importServiceDataRequest) { byte[] fileContentBytes; using (var readStream = importServiceDataRequest.FormFile.OpenReadStream()) { fileContentBytes = new byte[readStream.Length]; await readStream.ReadAsync(fileContentBytes, 0, (int)readStream.Length); } return(fileContentBytes); }