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,15 +1865,21 @@ sub send_gcode {
], ],
); );
}else{ }else{
$res = $ua->post( # slurp the file we would send into a string - should be someplace to reference this but could not find it?
"http://" . $self->{config}->print_host . "/rr_upload?name=0:/gcodes/" . basename($path) . "&time=1234567890123", local $/=undef;
Content_Type => 'form-data', open my $gch,$path;
Content => [ my $gcode=<$gch>;
# OctoPrint doesn't like Windows paths so we use basename() close($gch);
# Also, since we need to read from filesystem we process it through encode_path()
file => [ $path, basename($path) ], # 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}) { if ($self->{send_gcode_file_print}) {
$res = $ua->get( $res = $ua->get(
"http://" . $self->{config}->print_host . "/rr_gcode?gcode=M32%20" . basename($path), "http://" . $self->{config}->print_host . "/rr_gcode?gcode=M32%20" . basename($path),
@ -1881,6 +1887,8 @@ sub send_gcode {
} }
} }
} }
}
$self->statusbar->StopBusy; $self->statusbar->StopBusy;
if ($res->is_success) { if ($res->is_success) {