Specify plate index for the 3mf workflow (#14404)

feat: forward plateindex for index-coded .gcode.3mf uploads

Gcode inside a .gcode.3mf is index-coded (Metadata/plate_<N>.gcode) and a
bundle may carry several, so the upload must name which plate to print —
even a single-plate bundle, since its entry is still indexed.

A 1-based plate index is stored in PrintHostUpload::extended_info when use_3mf
is set; the OctoPrint and Moonraker hosts forward it as a `plateindex` form
field. Servers that don't use it ignore the unknown field, so the plain G-code
path is unchanged.
This commit is contained in:
SoftFever
2026-06-25 22:02:19 +08:00
committed by GitHub
parent 0c5d85e516
commit 688127af5b
4 changed files with 54 additions and 16 deletions
+11 -3
View File
@@ -237,18 +237,26 @@ bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn progress_fn, Erro
bool result = true;
std::string uploaded_path;
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% to %3% (root=%4%, filename=%5%, start_print=%6%)")
//ORCA: gcode inside a .gcode.3mf is index-coded (Metadata/plate_<N>.gcode), so the upload names the
// plate via a 1-based `plateindex` (set only in the .3mf path, see Plater::send_gcode_legacy);
// servers that don't use it ignore the unknown form field.
const std::string plateindex = upload_data.extended("plateindex");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% to %3% (root=%4%, filename=%5%, plateindex=%6%, start_print=%7%)")
% name
% upload_data.source_path
% url
% root
% upload_filename.string()
% (plateindex.empty() ? "-" : plateindex)
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false");
auto http = Http::post(std::move(url));
set_auth(http);
http.form_add("root", root)
.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
http.form_add("root", root);
if (!plateindex.empty())
http.form_add("plateindex", plateindex);
http.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
.on_complete([&](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: upload HTTP %2%: %3%") % name % status % body;
try {