fix: Printables 다운로드 — fileType '3mf'가 API enum에 없어 400이던 문제(목록 종류 stl/gcode로 전달)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2496658b7d
commit
4641c3f820
1 file changed
+6
-4
@@ -294,15 +294,17 @@ async function resolvePrintablesDownload(id: string, cookie?: string): Promise<R
|
||||
});
|
||||
if (d.status >= 400 || !d.json?.data?.print) throw new Error(`Printables 모델 조회 실패: HTTP ${d.status} ${d.text.slice(0, 200)}`);
|
||||
const files: any[] = [
|
||||
...(d.json.data.print.stls || []),
|
||||
...(d.json.data.print.gcodes || []),
|
||||
].map((f: any) => ({ id: String(f.id), name: String(f.name || ''), size: Number(f.fileSize) || 0 }));
|
||||
...(d.json.data.print.stls || []).map((f: any) => ({ ...f, _kind: 'stl' })),
|
||||
...(d.json.data.print.gcodes || []).map((f: any) => ({ ...f, _kind: 'gcode' })),
|
||||
].map((f: any) => ({ id: String(f.id), name: String(f.name || ''), size: Number(f.fileSize) || 0, kind: f._kind as string }));
|
||||
const pick = pickSlicableFile(files);
|
||||
if (!pick) {
|
||||
const exts = [...new Set(files.map((f: any) => path.extname(f.name).toLowerCase()).filter(Boolean))].join(', ');
|
||||
throw new Error(`Printables 모델 ${id}에 슬라이싱 가능한 STL/3MF 파일이 없습니다${exts ? ` (있는 파일 형식: ${exts})` : ''} — 웹에서 직접 받아야 합니다.`);
|
||||
}
|
||||
const fileType = /\.3mf$/i.test(pick.name) ? '3mf' : 'stl';
|
||||
// DownloadFileTypeEnum엔 '3mf'가 없다(2026-09-29 실측: 400 invalid value). .3mf도 stls 목록에 들어 있고
|
||||
// fileType은 목록 종류(stl/gcode)로 넘긴다.
|
||||
const fileType = (pick as any).kind === 'gcode' ? 'gcode' : 'stl';
|
||||
const dlBody = {
|
||||
operationName: 'GetDownloadLink',
|
||||
query: `mutation GetDownloadLink($id: ID!, $modelId: ID!, $fileType: DownloadFileTypeEnum!, $source: DownloadSourceEnum!) { getDownloadLink(id: $id, printId: $modelId, fileType: $fileType, source: $source) { ok errors { field } output { link } } }`,
|
||||
|
||||
Reference in new issue
Block a user