// POST: api/Slice public async Task <string> Post([FromBody] string filepath, [FromUri] int fill = 20, [FromUri] double layer = 0.3, [FromUri] bool support = false) { var octoConnection = await WebApiApplication.GetOctoConnectionAsync(); var octofile = OctoPrintFileServices.CreateOctoFile(octoConnection, filepath); if (octofile != null) { string downloadpath = octoConnection.ApplicationFolderPath; octofile.DownloadAssociatedOnlineFile("local", downloadpath, octoConnection); // Change to be a global class instance and just set the slicing variables with every request // would be better not to create a new instance with each request PrusaSlicerBroker prusaSlicer = new PrusaSlicerBroker(prusaSlicerPath, fill, layer, support); //await octofile.Slice(prusaSlicer, octofile.SlicedFilePath); await prusaSlicer.SliceAsync(octofile.LocalFilePath); octofile.SetSlicedInPlaceFileInfo(); var uploadResponse = await octofile.UploadToOctoprintAsync(octofile.SlicedFilePath, octoConnection); if (uploadResponse.Contains("done\":true")) { return($"{octofile.SlicedFileName}"); } else { var errorResponse = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Problem occured while uploading sliced file to Octoprint"); throw new HttpResponseException(errorResponse); } } else { var errorResponse = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Problem occured while downloading file from Octoprint"); throw new HttpResponseException(errorResponse); } }