in reply to Re^2: LWP::Useragent - File Upload
in thread LWP::Useragent - File Upload
my $json = JSON->new; my $ua = LWP::UserAgent->new(); $ua->ssl_opts( SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE +, SSL_hostname => '', verify_hostname => 0 ); $ua->default_header('Content-Type' => 'application/json' ); $ua->default_header('Content_Type' => 'form-data;boundary=xYzZY'); $ua->default_header('Authorization', "Basic " . encode_base64("adm +in:Password123!")); $ua->timeout(600); my $file = { select => "/tmp/test_image.tgz.bin"}; my $url = "https://10.248.179.31/api/rest/software_package"; my $json_obj = $json->pretty->encode ($file); my $header = ['Content-Type' => 'multipart/form-data']; my $request = HTTP::Request->new("POST", $url, $header, $file); print Dumper $request; my $res = $ua->request($request);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: LWP::Useragent - File Upload
by bliako (Abbot) on Dec 20, 2018 at 22:04 UTC |