sub pushToImageServer { my $imageFullPath = $_[0]; my $imageFileName = $_[1]; my $contentType = $_[2]; my $userName = $_[3]; my $fileNameNoExt = $_[4]; my $FAILURE = 'Response: Failed'; my $SUCCESS = 'Response: Success'; logEvent(qq(Pushing "$imageFileName" to $CONFIGURATION->{imageserv +er})) if $CONFIGURATION->{verbose}; #my $CONFIGURATION->{imageserver}Path = "/up/" . $CONFIGURATION->{ +password} . "/" . $CONFIGURATION->{application} . "/" . $imageFileNam +e; my $imageServerPath = "/up/" . $CONFIGURATION->{password} . "/" . +$CONFIGURATION->{application} . "/" . $userName . "/"; ## CS URL ##my $URL = 'http://' . $CONFIGURATION->{imageserver} . $imageServ +erPath; ## IS URL ##$imageServerPath =~ s/\/$//; ## Strip off trailing slash my $URL = 'http://' . $CONFIGURATION->{imageserver} . $imageServer +Path . "?width=" . $CONFIGURATION->{validimagewidth} . "&height=" . $ +CONFIGURATION->{validimageheight} . "&type=" . $CONFIGURATION->{desir +edformat} . "&name=" . $fileNameNoExt; logEvent("Image Server URL: $URL") if $CONFIGURATION->{verbose}; ## POST my $ua = LWP::UserAgent->new; my $imageBody = [$CONFIGURATION->{filekey}=>[$imageFullPath,$image +FileName,'Content-Type'=>$contentType]]; my $POST = POST($URL, Content_Type => 'form-data',Connection => 'C +lose',Host => $CONFIGURATION->{imageserver}, Content=>$imageBody); ## GET my $return = $ua->request($POST); my $returnString = $return->as_string; #logEvent("Received From $CONFIGURATION->{imageserver}: $returnStr +ing"); logEvent("Received From $CONFIGURATION->{imageserver}: $returnStri +ng") if $CONFIGURATION->{verbose}; unless ( $returnString =~ /$SUCCESS/ ) { logEvent("Received FAILURE Response from $CONFIGURATION->{imag +eserver}"); return 0; } return 1; }
In reply to Cannot post image using LWP by shinobu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |