diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 1f3b8c0..b879eae 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -191,7 +191,8 @@ function M.fetch_POST(request, response) local socket = printer:getId() local remote = settings.get('gcode_server') - io.popen("print-fetch.lua " .. socket .. " " .. remote) + local id = request:get("id") + io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id) end --requires: gcode(string) (the gcode to be appended) diff --git a/src/script/print-fetch.lua b/src/script/print-fetch.lua index bba863a..12e1c48 100755 --- a/src/script/print-fetch.lua +++ b/src/script/print-fetch.lua @@ -10,7 +10,9 @@ local remote = arg[2] local finished = false -local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/"):read("*a")) +local id = arg[3] + +local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/" .. id):read("*a")) local current_line = 0 local total_lines = tonumber(info["lines"]) @@ -18,7 +20,7 @@ local started = false while(not finished) do - local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. current_line) + local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line) local line = f:read() while line ~= nil do printer:appendGcode(line)