in reply to Re: Upload file to REST service
in thread Upload file to REST service
perl -wc file doesn't complain, but when running I get "Can't call method "request" on an undefined value ". $req is defined, and shown on the line above, but the code doesn't get to the "something went wrong" line.open my $up, "<", "$_[0]" or die "Something went wrong: ".$!; binmode +$up; my $ck = Digest::MD5->new; $ck->addfile($up); close $up; my $us = HTTP::Headers->new; $us->header(Content_Type => 'multipart/fo +rm-data'); my $req = HTTP::Request->new('POST',"https://".$server."/file_bucket_f +ile/md5/".$_[1]."/".$ck->hexdigest, $us, [ file => ["$_[0]"] ]); print Dumper($req); my $res = $ua->request($req); die "Something went wrong: ".$res->status_line unless $res->is_success +;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Upload file to REST service
by Anonymous Monk on Jun 02, 2011 at 05:21 UTC | |
by rgcosma (Beadle) on Jun 02, 2011 at 15:38 UTC | |
by rgcosma (Beadle) on Jun 07, 2011 at 08:22 UTC |