From 12b3f0088d49c2fb064f775a6c6d26177a32f41d Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 4 Dec 2018 10:07:43 +0100 Subject: [PATCH] Add content type to file upload --- cura/PrinterOutput/NetworkedPrinterOutputDevice.py | 5 +++-- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index 5677106782..72b6319020 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -180,10 +180,11 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._createNetworkManager() assert (self._manager is not None) - def put(self, target: str, data: Union[str, bytes], on_finished: Optional[Callable[[QNetworkReply], None]], + def put(self, target: str, data: Union[str, bytes], content_type: str = None, + on_finished: Optional[Callable[[QNetworkReply], None]] = None, on_progress: Optional[Callable] = None) -> None: self._validateManager() - request = self._createEmptyRequest(target) + request = self._createEmptyRequest(target, content_type = content_type) self._last_request_time = time() if self._manager is not None: reply = self._manager.put(request, data if isinstance(data, bytes) else data.encode()) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index e2957cacae..63a109cf5c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -375,7 +375,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): # TODO: Multipart upload job_response = JobUploadResponse(**response.get("data")) Logger.log("i", "Print job created successfully: %s", job_response.__dict__) - self.put(job_response.upload_url, data = mesh, + self.put(job_response.upload_url, data = mesh, content_type = job_response.content_type, on_finished = lambda r: self._onPrintJobUploaded(job_response.job_id, r), on_progress = self._onUploadPrintJobProgress)