1
我想通過它的API將gcode文件上傳到我的八段打印。 鏈接到其文檔:http://docs.octoprint.org/en/master/api/files.html#upload-file-or-create-folder使用Octoprint API和GuzzleHttp上傳文件
Octoprint響應內部服務器錯誤。 在檢查其日誌文件,我發現下面幾行表示octoprints上傳功能的問題
File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.4-py2.7.egg/octoprin$
added_file = fileManager.add_file(FileDestinations.LOCAL, futureFullPathInStorage, uploa$
File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.4-py2.7.egg/octoprin$
self._analysis_queue.dequeue(queue_entry)
File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.4-py2.7.egg/octoprin$
if not entry.type in self._queues:
AttributeError: 'NoneType' object has no attribute 'type'
我使用GuzzleHttp上傳的文件,調用API網址/ API /文件/本地
public function printFile(Raspi $raspi,$file) {
$fileName = basename($file);
$result = $this->callAPIMethod($raspi, '/api/files/local', [
'multipart' => [
[
'name' => 'file',
'contents' => Storage::get($filePath),
'filename' => $fileName
],
[
'name' => 'print',
'contents' => true,
]
]
],"post");
$raspi->status = "druckt";
$raspi->save();
}
private function callAPIMethod(Raspi $raspi,$apiPath,$commandParams,$method='get') {
$client = new Client();
$apiKey = $raspi->key;
$params = [
'headers' => [
'X-API-Key' => $apiKey,
]
];
if($commandParams != NULL)
$params = array_merge ($params, $commandParams);
switch($method) {
case "get":
return $client->get($raspi->ip.":".RaspiApiController::$APIPORT."/".$apiPath, $params);
break;
case "post":
return $client->post($raspi->ip.":".RaspiApiController::$APIPORT.$apiPath, $params);
break;
case "delete":
return $client->delete($raspi->ip.":".RaspiApiController::$APIPORT."/".$apiPath, $params);
break;
default:
return $client->get($raspi->ip.":".RaspiApiController::$APIPORT."/".$apiPath, $params);
break;
}
}
如何我是否必須在Guzzle中更改我的請求以防止發生此錯誤?