2012-02-18 74 views
3

該請求返回ZIP類型的文件,我如何從該請求中檢索該文件?perl post後下載文件

# put timeouts, proxy etc into the useragent if needed 
my $ua = LWP::UserAgent->new(); 
my $req = POST $in_u, Content_Type => 'form-data', Content => $in_r; 

my $response = $ua->request($req); 

if ($response->is_success()) 
{ 
    print $response->content; 
} 

回答

2

我想你可以用你的$ REQ對象的內容的方法來獲取原始內容返回作爲POST的結果。如果內容很大,則content_ref方法更適合,並提供直接操作內容。

my $zfile = $req->content; 

和裂紋在$ zfile與存檔::郵編爲DVK建議。

2

您可以使用Archive::Zip CPAN模塊