Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2021-10-12 13:56:19 +0300
committerGhostkeeper <rubend@tutanota.com>2021-10-12 13:56:19 +0300
commitf0d69cbef271c4ac31a37c5e027deb1f9780e2c7 (patch)
tree8e93be96e5e926b44dfec45609ee9e5f46948ba3 /cura/PrinterOutput
parentd5e3ed4c0e9d626fbf569a8d48a0a924fbc54571 (diff)
Add file data to PUT request
The main point of the whole request, really. Contributes to issue CURA-8609.
Diffstat (limited to 'cura/PrinterOutput')
-rw-r--r--cura/PrinterOutput/UploadMaterialsJob.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cura/PrinterOutput/UploadMaterialsJob.py b/cura/PrinterOutput/UploadMaterialsJob.py
index e500d8d407..6acac515fe 100644
--- a/cura/PrinterOutput/UploadMaterialsJob.py
+++ b/cura/PrinterOutput/UploadMaterialsJob.py
@@ -35,6 +35,7 @@ class UploadMaterialsJob(Job):
super().__init__()
self._material_sync = material_sync
self._scope = JsonDecoratorScope(UltimakerCloudScope(cura.CuraApplication.CuraApplication.getInstance())) # type: JsonDecoratorScope
+ self._archive_filename = None # type: Optional[str]
uploadCompleted = Signal()
uploadProgressChanged = Signal()
@@ -42,8 +43,9 @@ class UploadMaterialsJob(Job):
def run(self):
archive_file = tempfile.NamedTemporaryFile("wb", delete = False)
archive_file.close()
+ self._archive_filename = archive_file.name
- self._material_sync.exportAll(QUrl.fromLocalFile(archive_file.name), notify_progress = self.uploadProgressChanged)
+ self._material_sync.exportAll(QUrl.fromLocalFile(self._archive_filename), notify_progress = self.uploadProgressChanged)
http = HttpRequestManager.getInstance()
http.get(
@@ -70,9 +72,11 @@ class UploadMaterialsJob(Job):
return
upload_url = response_data["upload_url"]
+ file_data = open(self._archive_filename, "rb").read()
http = HttpRequestManager.getInstance()
http.put(
url = upload_url,
+ data = file_data,
callback = self.onUploadCompleted,
error_callback = self.onError,
scope = self._scope