use blob instead of file so it can be used on ios9

This commit is contained in:
casperlamboo 2018-01-31 13:32:16 +01:00
parent dd007b8bbf
commit 4cea3b3086

View File

@ -156,7 +156,7 @@ export async function slice(target, name, mesh, settings, updateProgress) {
if (settings.printer === 'doodle3d_printer') { if (settings.printer === 'doodle3d_printer') {
const { state } = await getMalyanStatus(settings.ip); const { state } = await getMalyanStatus(settings.ip);
if (state !== 'idle') throw { message: 'printer is busy', code: 0 }; if (state !== 'idle') throw { message: 'printer is busy', code: 0 };
} else { } else {
wifiBox = new Doodle3DBox(settings.ip); wifiBox = new Doodle3DBox(settings.ip);
if (!await wifiBox.checkAlive()) throw { message: `can't connect to printer`, code: 4 } if (!await wifiBox.checkAlive()) throw { message: `can't connect to printer`, code: 4 }
@ -231,14 +231,14 @@ export async function slice(target, name, mesh, settings, updateProgress) {
body.append(key, fields[key]); body.append(key, fields[key]);
} }
const file = new File([`;${JSON.stringify({ const file = new Blob([`;${JSON.stringify({
...settings, ...settings,
name: `${name}.gcode`, name: `${name}.gcode`,
printer: { type: settings.printers, title: printerSettings[settings.printer].title }, printer: { type: settings.printers, title: printerSettings[settings.printer].title },
material: { type: settings.material, title: materialSettings[settings.material].title }, material: { type: settings.material, title: materialSettings[settings.material].title },
quality: { type: settings.quality, title: qualitySettings[settings.quality].title } quality: { type: settings.quality, title: qualitySettings[settings.quality].title }
}).trim()}\n${gcode}`], 'doodle.gcode'); }).trim()}\n${gcode}`]);
body.append('file', file); body.append('file', file, 'doodle.gcode');
await fetchProgress(url, { method: 'POST', body }, progress => { await fetchProgress(url, { method: 'POST', body }, progress => {
updateProgress({ updateProgress({