Duet upload improved to work with DuetWiFi and Duet 0.6(ethernet). Thanks to @rob-miller for testing and fix. (#4033)

This commit is contained in:
eMAKER 2017-06-17 21:02:47 +01:00 committed by Joseph Lenox
parent 98fca9090b
commit 5fbb245b97

View File

@ -1865,22 +1865,30 @@ sub send_gcode {
],
);
}else{
$res = $ua->post(
"http://" . $self->{config}->print_host . "/rr_upload?name=0:/gcodes/" . basename($path) . "&time=1234567890123",
Content_Type => 'form-data',
Content => [
# OctoPrint doesn't like Windows paths so we use basename()
# Also, since we need to read from filesystem we process it through encode_path()
file => [ $path, basename($path) ],
],
);
if ($self->{send_gcode_file_print}) {
$res = $ua->get(
"http://" . $self->{config}->print_host . "/rr_gcode?gcode=M32%20" . basename($path),
);
# slurp the file we would send into a string - should be someplace to reference this but could not find it?
local $/=undef;
open my $gch,$path;
my $gcode=<$gch>;
close($gch);
# get the time string
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $t = sprintf("%4d-%02d-%02dT%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
my $req = HTTP::Request->new(POST => "http://" . $self->{config}->print_host . "/rr_upload?name=0:/gcodes/" . basename($path) . "&time=$t",);
$req->content( $gcode );
$res = $ua->request($req);
if ($res->is_success) {
if ($self->{send_gcode_file_print}) {
$res = $ua->get(
"http://" . $self->{config}->print_host . "/rr_gcode?gcode=M32%20" . basename($path),
);
}
}
}
}
$self->statusbar->StopBusy;
if ($res->is_success) {