bambu-printer-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +339 -0
- package/README.md +85 -0
- package/dist/3mf_parser.d.ts +3 -0
- package/dist/3mf_parser.js +216 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +700 -0
- package/dist/printers/bambu.d.ts +50 -0
- package/dist/printers/bambu.js +350 -0
- package/dist/stl/stl-manipulator.d.ts +140 -0
- package/dist/stl/stl-manipulator.js +1102 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.js +1 -0
- package/package.json +52 -0
- package/src/3mf_parser.ts +223 -0
- package/src/index.ts +830 -0
- package/src/printers/bambu.ts +480 -0
- package/src/stl/stl-manipulator.ts +1377 -0
- package/src/types.ts +58 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import JSZip from "jszip";
|
|
5
|
+
import { Client as FTPClient } from "basic-ftp";
|
|
6
|
+
import { BambuPrinter } from "bambu-js";
|
|
7
|
+
import {
|
|
8
|
+
BambuClient,
|
|
9
|
+
GCodeFileCommand,
|
|
10
|
+
GCodeLineCommand,
|
|
11
|
+
PushAllCommand,
|
|
12
|
+
UpdateStateCommand,
|
|
13
|
+
} from "bambu-node";
|
|
14
|
+
|
|
15
|
+
interface BambuPrintOptionsInternal {
|
|
16
|
+
projectName: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
useAMS?: boolean;
|
|
19
|
+
plateIndex?: number;
|
|
20
|
+
bedLeveling?: boolean;
|
|
21
|
+
flowCalibration?: boolean;
|
|
22
|
+
vibrationCalibration?: boolean;
|
|
23
|
+
layerInspect?: boolean;
|
|
24
|
+
timelapse?: boolean;
|
|
25
|
+
amsMapping?: number[];
|
|
26
|
+
md5?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ProjectFileMetadata {
|
|
30
|
+
plateFileName: string;
|
|
31
|
+
plateInternalPath: string;
|
|
32
|
+
md5: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class BambuClientStore {
|
|
36
|
+
private printers: Map<string, BambuClient> = new Map();
|
|
37
|
+
private initialConnectionPromises: Map<string, Promise<void>> = new Map();
|
|
38
|
+
|
|
39
|
+
async getPrinter(host: string, serial: string, token: string): Promise<BambuClient> {
|
|
40
|
+
const key = `${host}-${serial}`;
|
|
41
|
+
|
|
42
|
+
if (this.printers.has(key)) {
|
|
43
|
+
return this.printers.get(key)!;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (this.initialConnectionPromises.has(key)) {
|
|
47
|
+
await this.initialConnectionPromises.get(key);
|
|
48
|
+
if (this.printers.has(key)) {
|
|
49
|
+
return this.printers.get(key)!;
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Existing Bambu client connection for ${key} failed.`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const printer = new BambuClient({
|
|
55
|
+
host,
|
|
56
|
+
serialNumber: serial,
|
|
57
|
+
accessToken: token,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
printer.on("client:connect", () => {
|
|
61
|
+
this.printers.set(key, printer);
|
|
62
|
+
this.initialConnectionPromises.delete(key);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
printer.on("client:error", () => {
|
|
66
|
+
this.printers.delete(key);
|
|
67
|
+
this.initialConnectionPromises.delete(key);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
printer.on("client:disconnect", () => {
|
|
71
|
+
this.printers.delete(key);
|
|
72
|
+
this.initialConnectionPromises.delete(key);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const connectPromise = printer.connect().then(() => {});
|
|
76
|
+
this.initialConnectionPromises.set(key, connectPromise);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await connectPromise;
|
|
80
|
+
return printer;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
this.initialConnectionPromises.delete(key);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async disconnectAll(): Promise<void> {
|
|
88
|
+
const disconnectPromises: Promise<void>[] = [];
|
|
89
|
+
|
|
90
|
+
for (const printer of this.printers.values()) {
|
|
91
|
+
disconnectPromises.push(
|
|
92
|
+
(async () => {
|
|
93
|
+
try {
|
|
94
|
+
await printer.disconnect();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("Failed to disconnect Bambu client", error);
|
|
97
|
+
}
|
|
98
|
+
})()
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await Promise.allSettled(disconnectPromises);
|
|
103
|
+
this.printers.clear();
|
|
104
|
+
this.initialConnectionPromises.clear();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class BambuImplementation {
|
|
109
|
+
private printerStore: BambuClientStore;
|
|
110
|
+
|
|
111
|
+
constructor() {
|
|
112
|
+
this.printerStore = new BambuClientStore();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private async getPrinter(host: string, serial: string, token: string): Promise<BambuClient> {
|
|
116
|
+
return this.printerStore.getPrinter(host, serial, token);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async resolveProjectFileMetadata(
|
|
120
|
+
localThreeMfPath: string,
|
|
121
|
+
plateIndex?: number
|
|
122
|
+
): Promise<ProjectFileMetadata> {
|
|
123
|
+
const archive = await fs.readFile(localThreeMfPath);
|
|
124
|
+
const zip = await JSZip.loadAsync(archive);
|
|
125
|
+
|
|
126
|
+
const plateEntries = Object.values(zip.files).filter(
|
|
127
|
+
(entry) => !entry.dir && /^Metadata\/plate_\d+\.gcode$/i.test(entry.name)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (plateEntries.length === 0) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
"3MF does not contain any Metadata/plate_<n>.gcode entries. Re-slice and export a printable 3MF."
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let selectedEntry = plateEntries.sort((a, b) => a.name.localeCompare(b.name))[0];
|
|
137
|
+
|
|
138
|
+
if (plateIndex !== undefined) {
|
|
139
|
+
const expectedEntryName = `Metadata/plate_${plateIndex + 1}.gcode`;
|
|
140
|
+
const matchedEntry = plateEntries.find(
|
|
141
|
+
(entry) => entry.name.toLowerCase() === expectedEntryName.toLowerCase()
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
if (!matchedEntry) {
|
|
145
|
+
const available = plateEntries.map((entry) => entry.name).join(", ");
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Requested plateIndex=${plateIndex} (${expectedEntryName}) not present in 3MF. Available: ${available}`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
selectedEntry = matchedEntry;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const gcodeBuffer = await selectedEntry.async("nodebuffer");
|
|
155
|
+
const md5 = createHash("md5").update(gcodeBuffer).digest("hex");
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
plateFileName: path.posix.basename(selectedEntry.name),
|
|
159
|
+
plateInternalPath: selectedEntry.name,
|
|
160
|
+
md5,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async getStatus(host: string, serial: string, token: string): Promise<any> {
|
|
165
|
+
try {
|
|
166
|
+
const printer = await this.getPrinter(host, serial, token);
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
await printer.executeCommand(new PushAllCommand());
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.warn("PushAllCommand failed, continuing with cached status", error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!printer.data || Object.keys(printer.data).length === 0) {
|
|
175
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const data = printer.data;
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
status: data.gcode_state || "UNKNOWN",
|
|
182
|
+
connected: true,
|
|
183
|
+
temperatures: {
|
|
184
|
+
nozzle: {
|
|
185
|
+
actual: data.nozzle_temper || 0,
|
|
186
|
+
target: data.nozzle_target_temper || 0,
|
|
187
|
+
},
|
|
188
|
+
bed: {
|
|
189
|
+
actual: data.bed_temper || 0,
|
|
190
|
+
target: data.bed_target_temper || 0,
|
|
191
|
+
},
|
|
192
|
+
chamber: data.chamber_temper || data.frame_temper || 0,
|
|
193
|
+
},
|
|
194
|
+
print: {
|
|
195
|
+
filename: data.subtask_name || data.gcode_file || "None",
|
|
196
|
+
progress: data.mc_percent || 0,
|
|
197
|
+
timeRemaining: data.mc_remaining_time || 0,
|
|
198
|
+
currentLayer: data.layer_num || 0,
|
|
199
|
+
totalLayers: data.total_layer_num || 0,
|
|
200
|
+
},
|
|
201
|
+
ams: data.ams || null,
|
|
202
|
+
model: data.model || "Unknown",
|
|
203
|
+
serial,
|
|
204
|
+
raw: data,
|
|
205
|
+
};
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error(`Failed to get Bambu status for ${serial}:`, error);
|
|
208
|
+
return { status: "error", connected: false, error: (error as Error).message };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async print3mf(
|
|
213
|
+
host: string,
|
|
214
|
+
serial: string,
|
|
215
|
+
token: string,
|
|
216
|
+
options: BambuPrintOptionsInternal
|
|
217
|
+
): Promise<any> {
|
|
218
|
+
if (!options.filePath.toLowerCase().endsWith(".3mf")) {
|
|
219
|
+
throw new Error("print3mf requires a .3mf input file.");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const projectMetadata = await this.resolveProjectFileMetadata(
|
|
223
|
+
options.filePath,
|
|
224
|
+
options.plateIndex
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const remoteFileName = path.basename(options.filePath);
|
|
228
|
+
const remoteProjectPath = `cache/${remoteFileName}`;
|
|
229
|
+
|
|
230
|
+
// Upload via basic-ftp directly (bypasses bambu-js double-path bug)
|
|
231
|
+
await this.ftpUpload(host, token, options.filePath, `/cache/${remoteFileName}`);
|
|
232
|
+
|
|
233
|
+
// Send project_file command via bambu-node MQTT (bypasses bambu-js
|
|
234
|
+
// hardcoded use_ams=true and missing ams_mapping support)
|
|
235
|
+
const printer = await this.getPrinter(host, serial, token);
|
|
236
|
+
const md5 = options.md5 ?? projectMetadata.md5;
|
|
237
|
+
|
|
238
|
+
// Build AMS mapping per OpenBambuAPI spec: 5-element array
|
|
239
|
+
// [-1,-1,-1,-1,0] means slot 0 only; pad unused slots with -1
|
|
240
|
+
let amsMapping: number[];
|
|
241
|
+
if (options.amsMapping && options.amsMapping.length > 0) {
|
|
242
|
+
amsMapping = Array.from({ length: 5 }, (_, i) =>
|
|
243
|
+
i < options.amsMapping!.length ? options.amsMapping![i] : -1
|
|
244
|
+
);
|
|
245
|
+
} else {
|
|
246
|
+
amsMapping = [-1, -1, -1, -1, 0];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const projectFileCmd = {
|
|
250
|
+
print: {
|
|
251
|
+
command: "project_file",
|
|
252
|
+
param: `Metadata/${projectMetadata.plateFileName}`,
|
|
253
|
+
url: `file:///sdcard/${remoteProjectPath}`,
|
|
254
|
+
subtask_name: options.projectName,
|
|
255
|
+
md5,
|
|
256
|
+
flow_cali: options.flowCalibration ?? true,
|
|
257
|
+
layer_inspect: options.layerInspect ?? true,
|
|
258
|
+
vibration_cali: options.vibrationCalibration ?? true,
|
|
259
|
+
bed_leveling: options.bedLeveling ?? true,
|
|
260
|
+
bed_type: "textured_plate",
|
|
261
|
+
timelapse: options.timelapse ?? false,
|
|
262
|
+
use_ams: options.useAMS !== false,
|
|
263
|
+
ams_mapping: amsMapping,
|
|
264
|
+
profile_id: "0",
|
|
265
|
+
project_id: "0",
|
|
266
|
+
sequence_id: "0",
|
|
267
|
+
subtask_id: "0",
|
|
268
|
+
task_id: "0",
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
await printer.publish(projectFileCmd);
|
|
273
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
status: "success",
|
|
277
|
+
message: `Uploaded and started 3MF print: ${options.projectName}`,
|
|
278
|
+
remoteProjectPath,
|
|
279
|
+
plateFile: projectMetadata.plateFileName,
|
|
280
|
+
platePath: projectMetadata.plateInternalPath,
|
|
281
|
+
md5,
|
|
282
|
+
amsMapping,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async cancelJob(host: string, serial: string, token: string): Promise<any> {
|
|
287
|
+
const printer = await this.getPrinter(host, serial, token);
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
await printer.executeCommand(new UpdateStateCommand({ state: "stop" }));
|
|
291
|
+
return { status: "success", message: "Cancel command sent successfully." };
|
|
292
|
+
} catch (error) {
|
|
293
|
+
throw new Error(`Failed to cancel print: ${(error as Error).message}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async setTemperature(
|
|
298
|
+
host: string,
|
|
299
|
+
serial: string,
|
|
300
|
+
token: string,
|
|
301
|
+
component: string,
|
|
302
|
+
temperature: number
|
|
303
|
+
) {
|
|
304
|
+
const printer = await this.getPrinter(host, serial, token);
|
|
305
|
+
|
|
306
|
+
const normalizedComponent = component.toLowerCase();
|
|
307
|
+
const targetTemperature = Math.round(temperature);
|
|
308
|
+
|
|
309
|
+
if (targetTemperature < 0 || targetTemperature > 300) {
|
|
310
|
+
throw new Error("Temperature must be between 0 and 300°C.");
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let gcode: string;
|
|
314
|
+
if (normalizedComponent === "bed") {
|
|
315
|
+
gcode = `M140 S${targetTemperature}`;
|
|
316
|
+
} else if (
|
|
317
|
+
normalizedComponent === "extruder" ||
|
|
318
|
+
normalizedComponent === "nozzle" ||
|
|
319
|
+
normalizedComponent === "tool" ||
|
|
320
|
+
normalizedComponent === "tool0"
|
|
321
|
+
) {
|
|
322
|
+
gcode = `M104 S${targetTemperature}`;
|
|
323
|
+
} else {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`Unsupported temperature component: ${component}. Use one of: bed, nozzle, extruder.`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
await printer.executeCommand(new GCodeLineCommand({ gcodes: [gcode] }));
|
|
330
|
+
return {
|
|
331
|
+
status: "success",
|
|
332
|
+
message: `Temperature command sent for ${normalizedComponent}.`,
|
|
333
|
+
command: gcode,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async getFiles(host: string, serial: string, token: string) {
|
|
338
|
+
const printer = new BambuPrinter(host, serial, token);
|
|
339
|
+
const directories = ["cache", "timelapse", "logs"];
|
|
340
|
+
const filesByDirectory: Record<string, string[]> = {};
|
|
341
|
+
|
|
342
|
+
await printer.manipulateFiles(async (context) => {
|
|
343
|
+
for (const directory of directories) {
|
|
344
|
+
try {
|
|
345
|
+
filesByDirectory[directory] = await context.readDir(directory);
|
|
346
|
+
} catch {
|
|
347
|
+
filesByDirectory[directory] = [];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const files = Object.entries(filesByDirectory).flatMap(([directory, names]) =>
|
|
353
|
+
names.map((name) => `${directory}/${name}`)
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
files,
|
|
358
|
+
directories: filesByDirectory,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async getFile(host: string, serial: string, token: string, filename: string) {
|
|
363
|
+
const printer = new BambuPrinter(host, serial, token);
|
|
364
|
+
|
|
365
|
+
const normalized = filename.replace(/^\/+/, "");
|
|
366
|
+
const directory = path.posix.dirname(normalized) === "." ? "cache" : path.posix.dirname(normalized);
|
|
367
|
+
const baseName = path.posix.basename(normalized);
|
|
368
|
+
|
|
369
|
+
let exists = false;
|
|
370
|
+
|
|
371
|
+
await printer.manipulateFiles(async (context) => {
|
|
372
|
+
const entries = await context.readDir(directory);
|
|
373
|
+
exists = entries.includes(baseName);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
name: `${directory}/${baseName}`,
|
|
378
|
+
exists,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async uploadFile(
|
|
383
|
+
host: string,
|
|
384
|
+
serial: string,
|
|
385
|
+
token: string,
|
|
386
|
+
filePath: string,
|
|
387
|
+
filename: string,
|
|
388
|
+
print: boolean
|
|
389
|
+
) {
|
|
390
|
+
await fs.access(filePath);
|
|
391
|
+
|
|
392
|
+
const normalizedFileName = filename.replace(/^\/+/, "");
|
|
393
|
+
const remotePath = normalizedFileName.includes("/")
|
|
394
|
+
? normalizedFileName
|
|
395
|
+
: `cache/${normalizedFileName}`;
|
|
396
|
+
|
|
397
|
+
// Use direct FTP upload (bypasses bambu-js double-path bug)
|
|
398
|
+
await this.ftpUpload(host, token, filePath, `/${remotePath}`);
|
|
399
|
+
|
|
400
|
+
const response: Record<string, unknown> = {
|
|
401
|
+
status: "success",
|
|
402
|
+
uploaded: true,
|
|
403
|
+
remotePath,
|
|
404
|
+
printRequested: print,
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
if (print) {
|
|
408
|
+
if (remotePath.toLowerCase().endsWith(".gcode")) {
|
|
409
|
+
response.startResult = await this.startJob(host, serial, token, remotePath);
|
|
410
|
+
} else if (remotePath.toLowerCase().endsWith(".3mf")) {
|
|
411
|
+
response.note =
|
|
412
|
+
"3MF upload complete. Use print_3mf to start a project print with plate and metadata options.";
|
|
413
|
+
} else {
|
|
414
|
+
throw new Error(
|
|
415
|
+
"Automatic print after upload supports .gcode only. Use print_3mf for .3mf project prints."
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return response;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
async startJob(host: string, serial: string, token: string, filename: string) {
|
|
424
|
+
if (filename.toLowerCase().endsWith(".3mf")) {
|
|
425
|
+
throw new Error("Use print_3mf for .3mf project files.");
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const printer = await this.getPrinter(host, serial, token);
|
|
429
|
+
|
|
430
|
+
const normalizedFileName = filename.replace(/^\/+/, "");
|
|
431
|
+
const remoteFile = normalizedFileName.includes("/")
|
|
432
|
+
? normalizedFileName
|
|
433
|
+
: `cache/${normalizedFileName}`;
|
|
434
|
+
|
|
435
|
+
await printer.executeCommand(new GCodeFileCommand({ fileName: remoteFile }));
|
|
436
|
+
|
|
437
|
+
return {
|
|
438
|
+
status: "success",
|
|
439
|
+
message: `Start command sent for ${remoteFile}.`,
|
|
440
|
+
file: remoteFile,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Upload a file to the printer via FTP using basic-ftp directly.
|
|
446
|
+
* Bypasses bambu-js's sendFile which has a double-path bug (ensureDir CDs
|
|
447
|
+
* into the target directory, then uploadFrom uses the full relative path
|
|
448
|
+
* again, resulting in e.g. /cache/cache/file.3mf).
|
|
449
|
+
*/
|
|
450
|
+
private async ftpUpload(
|
|
451
|
+
host: string,
|
|
452
|
+
token: string,
|
|
453
|
+
localPath: string,
|
|
454
|
+
remotePath: string
|
|
455
|
+
): Promise<void> {
|
|
456
|
+
const client = new FTPClient(15_000);
|
|
457
|
+
try {
|
|
458
|
+
await client.access({
|
|
459
|
+
host,
|
|
460
|
+
port: 990,
|
|
461
|
+
user: "bblp",
|
|
462
|
+
password: token,
|
|
463
|
+
secure: "implicit",
|
|
464
|
+
secureOptions: { rejectUnauthorized: false },
|
|
465
|
+
});
|
|
466
|
+
// Use absolute path to avoid CWD side-effects
|
|
467
|
+
const absoluteRemote = remotePath.startsWith("/") ? remotePath : `/${remotePath}`;
|
|
468
|
+
const remoteDir = path.posix.dirname(absoluteRemote);
|
|
469
|
+
await client.ensureDir(remoteDir);
|
|
470
|
+
// uploadFrom with just the basename since we're already in the right dir
|
|
471
|
+
await client.uploadFrom(localPath, path.posix.basename(absoluteRemote));
|
|
472
|
+
} finally {
|
|
473
|
+
client.close();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async disconnectAll(): Promise<void> {
|
|
478
|
+
await this.printerStore.disconnectAll();
|
|
479
|
+
}
|
|
480
|
+
}
|